I have an MVC 5 site that also contains an API that's using Web API 2. I want to use Identity 2.0 to control access to the web pages - simple. But I want to use Basic Authentication or some other custom authentication on my api controllers, placed inside an Api folder (as is customary).
I have a custom IAuthenticationFilter written which controls access to the API, but if it returns a 401, Identity takes over and converts it to a 302 for redirection to the web site logon page. I want to prevent this conversion, but can't see any way.
In my OWIN Startup class's ConfigureAuth(IAppBuilder) method I have:
app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, oginPath = new PathString("/Account/LogOn") }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
My BasicAuthenticationFil ...

Go to the complete details ...