我正在尝试使用参数在我的mvc4应用上实现自定义授权属性。
我想要实现的目标是:
[Authorize(Application == "Initialize,Start,..." , Topic == "foo1,foo2,foo3...")]
public ActionResult Edit(int id)
{
//rest
}
该属性也应该能够装饰控制器,而不仅仅是方法
答案 0 :(得分:0)
您的custom authorization attribute:
public class UberAuthorizeAttr : System.Web.DomainServices.AuthorizationAttribute
{
public string Application {get;set;}
public string Topic {get;set;}
public override bool Authorize(System.Security.Principal.IPrincipal principal)
{
// your custom behaviour
}
}
你的控制器:
[UberAuthorizeAttr(Application = "Initialize,Start,..." , Topic = "foo1,foo2,foo3...")]
public ActionResult Edit(int id)
{
//rest
}
这就是你要找的东西吗?