Check whether the USER is authenticated/not while trying to browse using direct URL

64 Views Asked by At

Thanks in advance. I want to restrict users based on their authorization to my application while they are trying to access URL directly in browser. We are getting the flags from Database table whether the user has access to particular services or not. We are having n number of controllers, so I can't use session variables. Can you please suggest that how can I use those flags to restrict users by custom action filters.

1

There are 1 best solutions below

2
On

While your questions appears to be missing some details, looks like you are looking for an approach when you lot a lot of controllers and be able to authorize users to specific controllers/methods based on their rights.

[Authorize] attribute is specifically designed for that. Your requirement can be achieved using [Authorize] Attribute and adding some customization to it.

See here for an example of how to customize the authorize attribute. If you add more details to your question, may be we can provide some more thoughts and alternatives.