WEB API OnAuthorization is called twice

I am developing a solution for the web API for authorization, we process each controller action method with the BasicHttpAuthorizeAttribute class with inheritance from AuthorizeAttribute.

public class BasicHttpAuthorizeAttribute : System.Web.Http.AuthorizeAttribute

For each request, I see that the OnAuthorization method is called twice. when I check the column, the whole query is executed using a single thread / processId. I am using UnityContainer. I registered with Custom Authorize at WebApiConfig.cs. Please let me know the reason for the call twice.

+6
source share
1 answer

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

0
source

All Articles