OwinStartup not Starting … Why?

2019-01-19 12:20发布

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条回答
该账号已被封号
2楼-- · 2019-01-19 12:21

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>
查看更多
做自己的国王
3楼-- · 2019-01-19 12:37

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

查看更多
Fickle 薄情
4楼-- · 2019-01-19 12:47

Using

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

Is the answer.

查看更多
登录 后发表回答