public class CustomAuthorizeAttribute : AuthorizationFilterAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return true;// if my current user is authorised
}
}
以上是我的CustomAuthorizeAttribute类
[CustomAuthorize] // both [CustomAuthorize] and [CustomAuthorizeAttribute ] I tried
public class ProfileController : ApiController
{
//My Code..
}
我打电话时
http://localhost:1142/api/Profile
它没有触发 CustomAuthorizeAttribute
而且我的FilterConfig类如下所示
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new CustomAuthorizeAttribute());
}
}
如果我漏掉了什么,请帮忙指出。