Restrict Area to a given role

此生再无相见时 提交于 2019-12-07 07:05:34

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/3291385/restrict-area-to-a-given-role

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!