限制区给定角色 [英] Restrict Area to a given role
本文介绍了限制区给定角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MVC2一个区域设置,名为管理/
,我想我只是想谁属于角色管理员有访问权限的用户。我知道我可以用装点每个方法[授权(角色=管理员)]
,但是这似乎有些单调乏味,当你谈论与多个操作多个控制器。
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?
推荐答案
您可以定义装饰与此属性,在该地区的所有控制器从派生一个基本的控制器。
You could define a base controller decorated with this attribute that all controllers in the area derive from.
这篇关于限制区给定角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文