Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is OnAuthorization called twice in my custom AuthorizationFilterAttribute?

Why is OnAuthorization called twice for my straight forward AuthorizationFilterAttribute?

public class ApiAuthenticateAttribute : AuthorizationFilterAttribute
{
   public void override OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
    {
        if(NotAuthorized())
            throw new Exception();

    }
}

First Call Stack

First Call Stack

Second Call Stack

Second Call Stack

like image 503
Omar Avatar asked Oct 02 '22 00:10

Omar


1 Answers

The problem was with Ninject.Web.WebApi. For some reason it was registering the filter twice. Updating the package to latest (v 3.2.1) fixed the issue.

like image 58
Omar Avatar answered Oct 05 '22 23:10

Omar