可以有多个 FilterAttributes 吗?
是否可以堆叠多个过滤器属性?例如,我有这个属性,它检查一个人是否有权“管理员”或“队列”,
[ClientPortalSecured("Administrator", "Queue")]
public ActionResult Index()
{
return View(this.GetModel());
}
但如果我想检查这些和其他东西怎么办?可以做这样的事情吗?
[ClientPortalSecured("Administrator", "Queue")]
[ClientPortalSecured("abc")]
public ActionResult Index()
{
return View(this.GetModel());
}
当我尝试此操作时,当前出现“重复的‘ClientPortalSecured’属性”编译器错误。
Is it possible to stack multiple filter attributes? For instance I have this attribute which checks if a person has permission to "Administrator" OR "Queue"
[ClientPortalSecured("Administrator", "Queue")]
public ActionResult Index()
{
return View(this.GetModel());
}
but what if I wanted to check for these AND something else? Is it possible to do something like this?
[ClientPortalSecured("Administrator", "Queue")]
[ClientPortalSecured("abc")]
public ActionResult Index()
{
return View(this.GetModel());
}
I currently get "Duplicate 'ClientPortalSecured' attribute" compiler error when I try this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了。将
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)]
添加到我的 ClientPortalSecuredAttribute 类
found it. Added
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)]
to my ClientPortalSecuredAttribute class