jon jon
jon jon

Reputation: 25

How do I restrict access to certain groups for an entire controller?

I understand I can use decorators and filters, but then wouldn't I have to specify at the top of every ActionResult? Need something of a blanket approach to the entire controller.

Upvotes: 0

Views: 62

Answers (1)

Jeff Ogata
Jeff Ogata

Reputation: 57803

You can use the AuthorizeAttribute on the controller:

When you mark an action method with AuthorizeAttribute, access to that action method is restricted to users who are both authenticated and authorized. If you mark a controller with the attribute, all action methods in the controller are restricted.

Upvotes: 4

Related Questions