答案 0 :(得分:1)
只需扩展AuthorizeAttribute并覆盖AuthorizeCore,添加您自己的逻辑并返回true或false。
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var defaultResult = base.AuthorizeCore(httpContext);
// custom logic
return true; // or false
}
}