Limit scope to a specific role

I have a scope setting in MVC2 called Admin/, and I want only to want users belonging to the β€œadmins” role to have access. I know that I can decorate each of the methods with [Authorize(Roles="admins")], but it seems tedious when you talk about multiple controllers with multiple actions.

Is there a better and cleaner way?

+3
source share
1 answer

You can define a base controller, decorated with this attribute, from which all the controllers in the area are made.

+6
source

Source: https://habr.com/ru/post/1755539/


All Articles