ASP.net MVC身份验证Cookie在关闭浏览器后被解雇

时间:2014-11-05 16:36:10

标签: asp.net-mvc cookies asp.net-identity

我正在使用ASP.Net MVC 5和Identity。在Startup.Auth类中我有这个方法:

  public void ConfigureAuth(IAppBuilder app)
    {


        // important to register UserManager creation delegate. Won't work without it
        app.CreatePerOwinContext(DatabaseContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);



        // Enable the application to use a cookie to store information for the signed in user
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            Provider = new CookieAuthenticationProvider
            {
                // Enables the application to validate the security stamp when the user logs in.
                // This is a security feature which is used when you change a password or add an external login to your account.  
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User>(
                    validateInterval: TimeSpan.FromDays(365),
                    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))

            },
            ExpireTimeSpan = TimeSpan.FromDays(365),


        });
        // Use a cookie to temporarily store information about a user logging in with a third party login provider
        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);


    }

由于某些原因,当我退出Chrome时,Cookie会被持久存在,但是当我退出IE或Firefox时,Cookie被删除(并且这不会发生在其他页面上)。我该如何解决这个问题?

0 个答案:

没有答案