Sebastián Guerrero
Sebastián Guerrero

Reputation: 1114

OwinStartup stop firing with IIS ( but still working with IIS Express )

I have a Web API 2 application, hosted on IIS.

To configure OWIN, it has an startup class similar to this:

[assembly: OwinStartup(typeof(Startup))]
namespace Application.Api
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            throw new Exception("Owin startup class fired"); // Added for test pourposes
        }
    }
}

The app was working like a charm until it stops firing the Startup class: no any change in the config file, no packages updates, the file Microsoft.Owin.Host.SystemWeb.dll is present in the bin folder, the configuration is ok, etc.

Only it stops working, but if I set the project as Startup Project and run it with F5 using IIS Express the startup class is loaded correctly.

I checked other posts with probably causes without luck:

etc.

Upvotes: 5

Views: 2316

Answers (2)

jross
jross

Reputation: 269

I had the same problem and searched and tried so many things. It turned out I had to "Enable 32-bit Applications" in the application pool that my app on IIS was using. Here's how:

On the Server you deployed your OWIN Application to...

  1. Open IIS

  2. Go to Application Pools

  3. Right click on the application pool your OWIN app is using and click "advanced settings" (if you don't know what application pool your OWIN app is using, right click on your app -> "manage website" -> "advanced settings" -> "Application Pool" is the first item on list)

  4. Set "Enable 32-bit Applications" to true

  5. Restart app and if that was the problem, you app should now work.

Upvotes: 3

Sebastián Guerrero
Sebastián Guerrero

Reputation: 1114

Seems to be a problem with TEMP files of ASP and IIS.

So, to fix it, I followed the next steps:

  1. From Visual Studio, Build => Clean Solution.
  2. Close Visual Studio.
  3. Delete all files from your project bin folder.
  4. Delete all files from your project obj folder.
  5. Remove ASP.Net temp files: on my installation, they are located into: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root and into: C:\Users\[Your User]\AppData\Local\Temp\Temporary ASP.NET Files\.
  6. Delete the IIS temp files. You can find the location opening your IIS Manager and selecting .NET Compilation: enter image description here Into Assemblies group you will see the setting Temporary Directory: enter image description here ( G:\TEMP in my installation )
  7. Remove your API project site from IIS, and add it again.
  8. Enter Visual Studio, Build => Rebuild Solution.
  9. Test it.

I hope this help someone; I spent a lot of time with this nasty issue.

Upvotes: 3

Related Questions