13

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?

Dave New
  • 34,265
  • 48
  • 183
  • 366
Miguel Moura
  • 28,129
  • 59
  • 187
  • 356
  • `` Presumably you want `AutomaticAppStartup` to be `true` ? Note that [these instructions](http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection) are not step-by-step. The first list shows you different options. – ta.speot.is Nov 04 '13 at 02:02
  • 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 : http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection – Praburaj Nov 04 '13 at 02:21
  • Thank you. That was the problem ... I miss interpret the information on owin. – Miguel Moura Nov 04 '13 at 10:41
  • Possible duplicate of [OwinStartup not firing](http://stackoverflow.com/questions/20203982/owinstartup-not-firing) – John Sep 08 '16 at 08:41

3 Answers3

31

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>
akokani
  • 760
  • 7
  • 18
15

Using

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

Is the answer.

Miguel Moura
  • 28,129
  • 59
  • 187
  • 356
  • I was having the same issue as the OP. I had my `Startup` class, as well as the OWIN attributes on it. I had also installed the `Owin.Host.SystemWeb` package. I didn't look at the web.config for this attribute, because I had never set it to fault. I assumed the package installation would set things up for me - I was wrong. Make sure you check for this configuration setting! – Origin Mar 21 '15 at 13:15
  • 1
    Where is it supposed to be in the config file? – Konrad Viltersten Aug 02 '16 at 20:22
  • @KonradViltersten: it is supposed to be in `` block – v.karbovnichy Sep 19 '16 at 18:28
0

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

Dave New
  • 34,265
  • 48
  • 183
  • 366