尽管扩展了TimeSpan,但用​​户仍然会注销

时间:2015-02-12 04:57:01

标签: c# asp.net asp.net-mvc-5

我试图让用户登录更长的时间,比如一年左右。所以我改变了

TimeSpan.FromMinutes(30),

TimeSpan.FromDays(365),

在我的startup.auth.cs

如代码中所示,但用户仍会在短时间后退出。我在这里做错了什么?

        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            Provider = new CookieAuthenticationProvider
            {
                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                    validateInterval: TimeSpan.FromDays(30),
                    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
            }
        });

        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

这是我web.config中的相关设置

  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>

0 个答案:

没有答案