允许多个角色访问控制行动 [英] Allow multiple roles to access controller action
本文介绍了允许多个角色访问控制行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在,我布置这样的方法,让成员来访问我的控制器动作
[授权(角色=会员)]
如何允许多个角色例如下面不工作,但它显示了什么,我试图做(允许成员和admin访问):
[授权(角色=成员,管理员)]
解决方案
另一种选择是使用单一的授权过滤器为您发布,但取下内报价。 [授权(角色=成员管理)]
Right now I decorate a method like this to allow "members" to access my controller action
[Authorize(Roles="members")]
How do I allow more than one role? For example the following does not work but it shows what I am trying to do (allow "members" and "admin" access):
[Authorize(Roles="members", "admin")]
解决方案
Another option is to use a single authorize filter as you posted but remove the inner quotations.
[Authorize(Roles="members, admin")]
这篇关于允许多个角色访问控制行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文