7
votes

I'm developing web API solution for authorization, we decorated each controller action method with the BasicHttpAuthorizeAttribute class with inherits from AuthorizeAttribute.

public class BasicHttpAuthorizeAttribute : System.Web.Http.AuthorizeAttribute

For every request, I see OnAuthorization method is called twice. when I check the callstack, all the request is made by same thread/processId. I'm using UnityContainer. I registered by Custom Authorize in WebApiConfig.cs Please let me know the reason for calling twice.

1
Do you have any Preflight CORS Request ? - zapoo
Did you ever solve this? Having a very similar issue. - DevEng

1 Answers

4
votes

If you register a filter in webapiconfig.cs it will run for every incoming request. If you decorate an action with a filter, it will run for that action. Since you registered the filter and decorated the action, it will run two times.