No OWIN authentication manager is associated with the request

kid head slap

Have you ever seen the ASP.NET Web API Error Message, “No OWIN authentication manager is associated with the request”? I get this every time I generate a new ASP.NET Web API project, so I thought I would post this simple solution to keep me and hopefully you from making the same mistake in the future.

The reason you see this error when you try to run your shiny new API is you have removed the scaffolded authentication parts. I am sure I could generate an empty API project and avoid this issue. But I seem to always spend more time getting those projects running that it takes to just scrape out the extras included in the full project. Inevitably I forget a step or two, one being the fix to this exception.

In the scaffolded WebApiConfig.cs file, located in the App_Start folder, you need to remove or comment out the following lines:

//config.SuppressDefaultHostAuthentication();
//config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

You should now be able to run your API, assuming you have carved out the other extraneous references. Maybe I will learn to use the empty API template in the near future. To be honest I am waiting to see where vNext winds up before getting too committed to anything in the ASP.NET stack.

Microsoft .NET

Share This Article With Your Friends!

We use cookies to give you the best experience possible. By continuing, we'll assume you're cool with our cookie policy.

Install Love2Dev for quick, easy access from your homescreen or start menu.

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel