This a .NET 4.5 C# MVC + WebAPI 4 project. I am using the WebApiDoodle 2.0.1 BasicAuthenticationHandler to use MVC + WebAPI side by side security as explained here.
In my Application Start I add the Message Handler:
globalConfig.MessageHandlers.Add(new {MyClass Derived from BasicAuthenticationHandler}());
The MVC controllers work fine (classes derived from System.Web.Mvc.Controller
).
However, the WebApi controllers (derived from System.Web.Http.ApiController
) ignore the System.Web.Http.AllowAnonymous
attribute. They basically want to authenticate/authorize everything.
If I remove the custom message handler from the globalConfig the WebAPI works as expected, the AllowAnonymous attribute allows anonymous requests to be served (and actions that have [Authorize] are denied).
Any ideas what might be happening? Thanks.