views:

44

answers:

1

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?

+2  A: 

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

Darin Dimitrov
For clarification, Darin's post implies that if you stick the [Authorized] attribute on the controller type itself, it's the equivalent of having applied it to every method in that controller (or a subclassed controller).
Levi

related questions