简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM