允许多个角色访问控制器操作 [英] Allow multiple roles to access controller action
本文介绍了允许多个角色访问控制器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我装饰这样的方法,允许成员访问我的控制器操作
[Authorize(Roles = members)]
如何允许多个角色?例如以下不工作,但它显示我想要做的(允许成员和管理访问):
[Authorize(Roles =members,admin)]
解决方案<
[Authorize() Roles =members,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屋!
查看全文