Benutzerdefiniertes Berechtigungsattribut funktioniert in WebAPI nicht
public class CustomAuthorizeAttribute : AuthorizationFilterAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return true;// if my current user is authorised
}
}
Oben ist meine CustomAuthorizeAttribute-Klasse und
[CustomAuthorize] // both [CustomAuthorize] and [CustomAuthorizeAttribute ] I tried
public class ProfileController : ApiController
{
//My Code..
}
Wenn ich anrufe
http://localhost:1142/api/Profile
Es wird nicht geschossenCustomAuthorizeAttribute
Weitere Informationen zur My FilterConfig-Klasse finden Sie unten
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new CustomAuthorizeAttribute());
}
}
Bitte helfen Sie, wenn ich etwas vermisse.