14
votes

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?

3
<add key="owin:AutomaticAppStartup" value="false"/> Presumably you want AutomaticAppStartup to be true ? Note that these instructions are not step-by-step. The first list shows you different options.ta.speot.is
1) As mentioned by @ta.speot.is you may want to give a true value to the owin:AutomaticAppStartup appSetting. 2) Do you have Microsoft.Owin.Host.SystemWeb nuget package installed in your project? This package is required for the Startup class to be picked up. You can check out this tutorial for more information : asp.net/aspnet/overview/owin-and-katana/…Praburaj
Thank you. That was the problem ... I miss interpret the information on owin.Miguel Moura
Possible duplicate of OwinStartup not firingJohn

3 Answers

31
votes

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>
16
votes

Using

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

Is the answer.

0
votes

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