This project has moved and is read-only. For the latest updates, please go here.

IIS not executing startup class

Nov 18, 2013 at 9:42 PM
I have an OWIN demo app (one of ThinkTecture's samples) that runs beautifully from Visual Studio. However, when I publish it to a full IIS application on my local machine, it behaves as if IIS has not found the startup class. Specifically, I can browse to the app and see the directory (directory browsing is enabled), but when I try to access a URL that was set up in my startup class, I get a 404.0 error. Also, I put app.UseWelcomePage() in my startup class -- that works in Visual Studio, but is ignored when browsing to the IIS-hosted version.

I'm using the [assembly: OwinStartup(typeof(MyNamespacedStartupClass))] attribute to designate the startup class.

I've used NuGet to get both Microsoft.Owin.Host.SystemWeb and Microsoft.Owin.Diagnostics per instructions I've seen, but that doesn't make a difference.

What more do I have to do?
Nov 18, 2013 at 10:17 PM
Sounds like you're not deploying all the dependencies. If M.O.H.SystemWeb (v2) were running but not finding your startup it would show you an error page.

Make sure M.O.H.SystemWeb and it's dependencies are deployed.
Nov 18, 2013 at 10:29 PM
In my bin directory I have, in addition to my own DLLs,
  • Microsoft.Owin.dll
  • Microsoft.Owin.Diagnostics.dll
  • Microsoft.Owin.Host.SystemWeb.dll
  • Microsoft.Owin.Security.dll
  • Microsoft.Owin.Security.OAuth.dll
  • Owin.dll
  • System.Net.Http.Formatting.dll
  • System.Web.Http.dll
  • System.Web.Http.Owin.dll
  • System.Web.Http.WebHost.dll
That seems like a complete set, doesn't it?
Nov 18, 2013 at 11:08 PM
Have you tried any of these simpler samples for comparison?
https://aspnet.codeplex.com/SourceControl/latest#Samples/Katana/HelloWorld/Startup.cs
Nov 19, 2013 at 10:51 AM
I downloaded the HelloWorld sample and got the same result. When I run inside Visual Studio, "Hello World" appears in my browser. When I publish to my local IIS and then browse to it using Manage Application -> Browse in IIS Manager, I just get a directory listing (or a 403.14 if directory listing is disabled).

My publishing settings are as follows.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>C:\inetpub\wwwroot\KatanaHello</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
</Project>
Nov 19, 2013 at 10:59 AM
BTW, I'm running Windows Server 2008 R2, Datacenter edition. Help -> About Internet Information Services in IIS Manager says I have Windows Server Version 6.1 and Internet Information Services Version 7.5.7600.16385.
Nov 19, 2013 at 7:01 PM
Turns out that my default App Pool was set for version 2.0 of the .NET Framework! D'oh! Once I set it to v4.0, everything worked. ...thanks to Praburaj over at Stack Overflow.
Nov 19, 2013 at 7:18 PM
Ah, I didn't realize you were using the publishing wizard instead of the 'Create Virtual Directory' option in VS. When I tried that I was able to repro the issue. It looks like it creates the app in the DefaultAppPool by default, which is for .NET 2.0-3.5 apps. Going to Manage Application -> Advanced Settings I was able to change that to the ASP.NET v4.0 application pool and everything started to work. I don't see any way to choose this in the publishing wizard.