Search code examples
asp.net-mvc-2membershiprolesarea

Restrict Area to a given role


I have an area setup in MVC2, called Admin/, which I want I only want Users who belong to the role "admins" to have access. I know I can decorate each of the methods with [Authorize(Roles="admins")], but this seems tedious when your talking about multiple controllers with multiple actions.

Is there an better and cleaner way?


Solution

  • You could define a base controller decorated with this attribute that all controllers in the area derive from.