Miguel Moura
Miguel Moura

Reputation: 39354

OwinStartup not Starting ... Why?

I have the following class on an ASP.NET MVC 5 site:

[assembly: OwinStartup(typeof(MVCSite.Startup))]
namespace MVCSite {

  public partial class Startup {

    public void Configuration(IAppBuilder application) {

      application.UseCookieAuthentication(new CookieAuthenticationOptions {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login")
      });

      application.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
    }
  }
}

And on Web.Config I have the following:

<add key="owin:AutomaticAppStartup" value="false"/>

I have a breakpoint inside Startup.Configuration but this does not fire ...

Any idea why?

Upvotes: 14

Views: 18525

Answers (3)

Mohammad Kani
Mohammad Kani

Reputation: 942

It's usually happend because SystemWeb package is not installed on your project.

Use this command at your Package Manager Console:

Install-Package Microsoft.Owin.Host.SystemWeb

In the other hand you may use this configuration on your app.config or web.config if the above solution is not work:

<appSettings>
    <add key="owin:AutomaticAppStartup" value="true"/>
</appSettings>

Upvotes: 34

Revanth Siddoju
Revanth Siddoju

Reputation: 1

Try removing [assembly: OwinStartup(typeof(MVCSite.Startup))] and give a shot

Upvotes: 0

Miguel Moura
Miguel Moura

Reputation: 39354

Using

<add key="owin:AutomaticAppStartup" value="true"/>

Is the answer.

Upvotes: 16

Related Questions