My OWIN web service runs beautifully in Visual Studio 2013, but when I publish it to a real IIS site, it acts as if the Configuration method in the startup class has not bee
This article will have more information on how an OWIN middleware runs on Integrated pipeline.
I also faced same problems when I migrated my already running MVC5 site to a new server. It gave me nightmares, just to recap I had to do all this to get it working
[assembly: OwinStartupAttribute(typeof([YourAssemblyName].Startup))]
this to the Startup class (after the using statements and before the namespace declaration)Add these keys to the <appSettings>
section of web.config
<add key="owin:AppStartup" value="[NamespaceForYourStartUpClass].Startup, [YourAssemblyName]" />
<add key="owin:AutomaticAppStartup" value="true" />
And lastly as suggested by Martijn Evens add the following to <system.webserver>
section in web.config
<modules runAllManagedModulesForAllRequests="true" />
I also had to add an extra setting to my web.config
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
From: https://katanaproject.codeplex.com/wikipage?title=Static%20Files%20on%20IIS
IIS has a native static file module that is optimize to skip other portions of the pipeline if it sees file paths that do not match other handlers (e.g. not aspx). This means that the directory browser middleware is likely to work, but then the static file middleware may be bypassed in favor of the native static file module.
This tells IIS not to skip the managed Asp.Net modules even if the native static file module thinks it has a match.
It also describes another step, but this was not needed for me:
Also, add the following stage marker AFTER your static file middleware (in namespace Microsoft.Owin.Extensions): app.UseStageMarker(PipelineStage.MapHandler);
Probably the reason if you upgraded at some point from an older MVC:
Make sure you don't have
<add key="owin:AutomaticAppStartup" value="false" />
in your web.config
. It will suppress calling the startup
Instead change it to this
<add key="owin:AutomaticAppStartup" value="true" />
Somewhere along the line - when I upgraded to MVC 5 this got added (actually almost ironically it was a year ago tomorrow) and I never even knew what owin
was until today when I tried to use it.