Custom Authorization in Asp.net WebApi - what a mess?
问题 I\'m reading from several resources (books and SO answers) about authorization in WebApi. Suppose I want to add Custom Attribute which allows access only for Certain Users: Case #1 I\'ve seen this approach of overriding OnAuthorization , which sets response if something is wrong public class AllowOnlyCertainUsers : AuthorizeAttribute { public override void OnAuthorization(HttpActionContext actionContext) { if ( /*check if user OK or not*/) { actionContext.Response = new HttpResponseMessage