OWIN Startup class not detected
I've seen quite a lot of people running into the issue where their OWIN startup class is not detected. Here are some of the more common reasons why the OWIN startup class is not detected.
- Check if your IIS application pool is in Integrated mode. Note: Running of an OWIN middleware is supported only on IIS Integrated pipeline. Classic pool is not supported.
- Check if you have Microsoft.Owin.Host.SystemWeb Nuget package installed. This package is required for the OWIN startup class detection.
- [Learnt from comments - Thanks @Eric]: If your Startup class is still not detected in IIS, try it again by clearing the ASP.net temporary files.
Here is a detailed article on OWIN startup class detection for reference.
Comments
Anonymous
December 18, 2013
I have this issue. I have added OWIN to an existing MVC4 website that I first upgraded to MVC5. The AppPool is V4 Integrated and I have installed the OWIN Host SystemWeb via NuGet along with several other OWIN packages to prepare to add AspNet Identity. I added the Startup.cs file [assembly: OwinStartup(typeof(Store24Next.Web.Startup))] namespace Store24Next.Web { public partial class Startup { public void Configuration(IAppBuilder app) { ...etc... I set a breakpoint in the Configuration() function but it never breaks. I tried adding this to the appSettings but it did not help and I assume it is the default anyway. <add key="owin:AutomaticAppStartup" value="true"/> There is an existing Global.asax and it runs the Application_Start(). Is there anything needed or restricted in the Global and/or Web.Config? Thanks, GaryAnonymous
December 18, 2013
Oh, I did verify the bin folder contains the Microsoft.Owin.Host.SystemWeb. Also, I am using the pre-release version "2.1.0-rtw-21218-737-dev". GaryAnonymous
December 18, 2013
I changed the web property to use IIS Express instead of Local IIS and the breakpoint in the Configuration() function is now hit. Is there a way to use Local IIS? It seems like it should be possible according to the "class detection" document mentioned above. GaryAnonymous
December 18, 2013
@Gary the startup detection should work irrespective of IIS/IISExpress. If the breakpoint is hit in IISExpress, may be the break point will be hit in IIS as well - could you check if VS is attached to w3wp.exe correctly. Alternatively you could try one thing. Throw an exception from the Configuration() method to see if you get yellow screen of death which can confirm your Configuration method is invoked. Let me know how this goes.Anonymous
December 19, 2013
The comment has been removedAnonymous
December 19, 2013
I'm having the exact same issue. stackoverflow.com/.../signalr-2-0-error-signalr-hubs-404-not-found-when-using-iis Works just fine in IIS Express but the Local IIS doesn't recognize the assemblyAnonymous
December 19, 2013
Aaaand there I gave myself the clue to the error. IIS uses Temporary ASP.NET Files to cache binaries, IIS Express don't. Empty that cache and this error is gone.Anonymous
December 19, 2013
Thanks, Eric. Clearing the Temporary ASP.Net Files solved the IIS issue for me too. GaryAnonymous
December 20, 2013
Thanks @Eric, I updated the blog post with this pointer.Anonymous
August 07, 2014
I've just hit the same roadblock. Clearing Temporary ASP.NET Files didn't help. :( Owin Startup is hit under IIS Express, but not under local IIS. I'm on Win 7, 64 bit machine (IIS 7.5)Anonymous
August 13, 2014
Like Vladimir, I cleared the Temporary ASP.NET Files but was still not able to debug into the Startup.Configuration class when using Local IIS. I performed the following and it still did not work.
- Ensure I had the assembly attribute in the Startup.cs file ([assembly: OwinStartup(typeof(<your_app>.Startup))])
- Right-click on the Web Api project using OWIN --> Properties.
- In the Properties window, click on the "Web" tab and under "Start Action", select the last radio button "Don't open a page. Wait for a request from an external application."
- Launched Debug --> Attach to Process..." and selected "w3wp.exe" for local IIS worker process. I set the project properties to use IIS Express and I was still not able to launch the debugger into the Startup.Configuration() method. I set my project properties to use IIS Express and I was able to debug into the Startup.Configuration() method.
Anonymous
August 16, 2014
Like C. Kelly Wilson I have run into the same issue. Only since Upgrade 3 has this started happening...Anonymous
September 09, 2014
I'm surprised this issue STILL isn't fixed. I just deployed my application into a manage hosting environment and they are refusing to clear the Temporary ASP.NET Files folder for us. I have already verified in our debug environment that this is the culprit, as clearing this folder made OWIN work. Why is this even happening?Anonymous
September 16, 2014
I am using OWIN to host in IIS for WEB API. When a web API request sent i am expecting startup.configuration() to hit but it is not. Any thoughts, i am using web api 2.1. Also, Can I configure OWIN to handle only web API requests not any other requests. Just FYI, if i write app.use or app.run in configuration method then it will hit the break point.Anonymous
January 02, 2015
I ran into this issue as well and none of the suggestions worked for me. But I then found if I edited the web.config and changed <compilation debug="true" targetFramework="4.5" optimizeCompilations="true"> to <compilation debug="true" targetFramework="4.5" optimizeCompilations="false">, the problem cleared up. IIS seems to have some of the code precompiled. After running it successfully I was able to change back to "true".Anonymous
June 19, 2015
@Prabhu - I have tried all the steps provided above but still not working for me. When I switch to IISExpress then Startup class is being called. But in IIS, not working. I am using Win 7, IIS 6.1. I have included the Microsoft.Owin.Host.SystemWeb package, app pool set to integrated and everything else is set fine. But still Configure method in Startup class not called. Is there any other way or am I missing any other step? Please help!!!Anonymous
July 16, 2015
I have a problem after deployed my Web API to production server. I’m getting 404 error but only on the authentication request. We had no issues in all lower environments. I’ve run out of guesses what to try. The server is Windows 8 sp2 with IIS 7, Framework 4.5.1. <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> Please help! Thanks, IreneAnonymous
August 27, 2015
What Kevin said about changing optimizeCompilations from True to False did the trick for me. Thanks Kevin.Anonymous
October 02, 2015
Three more hints:
- check your build output is written to bin instead of a subfolder like bindebug
- check you have renamed your app.config to web.config
- check your namespace equals to the assembly name.
Anonymous
November 16, 2015
After renaming my project and solution startup.cs is not getting hit by debugger when i run the project in visual studio. I tried all the ways mentioned above but it is not hitting. why ?Anonymous
February 24, 2016
The comment has been removedAnonymous
March 01, 2016
Nice article thanks Praburaj...