Reputation: 3025
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.
Upvotes: 7
Views: 3699
Reputation: 1292
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.
Upvotes: 4