0
votes

I have multiple projects in a web solution that were a mix of OWIN startup and Global.asax startup. The OWIN startup project didn't have a global.asax and vis-versa. Today I tried to standardize the solution by adding startup.cs to all the Global.asax startup projects and deleting Global.asax. However, none of my projects with the new startup classes will actually startup.

I have tried:

1) Running Install-Package Microsoft.Owin.Host.SystemWeb in Nuget

2) Adding the following config keys to web.config:

<add key="owin:appStartup" value="namespace.Startup, assembly" />
<add key="owin:AutomaticAppStartup " value="true" />

3) Deleting the temp ASP.NET files (the ones in %temp% and the ones in C:\Windows\Microsoft.NET\Framework\v4.0.30319)

4) Making sure the class is just named Startup

5) Deleting the Startup class and re-adding the official way by selecting Add -> New Item -> OWIN Startup Class.

This is happening in IISExpress in my debug environment, I haven't tried it in production.

I cannot tell the difference between the project that has a working startup class and the ones that don't. The only major difference seems to be that the working project has net45 and not net46 listed as the targetFramework for the Owin and Microsoft.web.Infrastructure packages, but I can't think this would make a difference. Also the working project has SignalR installed and the others don't.

These projects all started from an Empty web project with Web API (no MVC), but I don't remember if I specified which ones had OWIN startup.

1
In case it helps anyone, there are also some suggestions here: stackoverflow.com/q/20203982/943746niki b

1 Answers

2
votes

owin:appStartup should be inside appSettings

<appSettings>
    <add key="owin:appStartup" value="NAMESPACE.Startup" />
</appSettings>  

If it is still doesn't work, you can try with OwinStartup Attribute.

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(YOUR_PROJECT_NAMESPACE.Startup))]
namespace YOUR_PROJECT_NAMESPACE
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
        }
    }
}

Note: You do not need owin:appStartup and owin:AutomaticAppStartup in web.config anymore.