1
所以我有一个MVC5的Web应用程序,我使用内置的ASP.Identity框架进行身份验证。我想让我的用户保持30天的登录状态。ASP身份CookieAuthentication不能正常工作
这里是我的代码在Startup.Auth.cs
:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieName = "Test",
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, ApplicationUser>(
validateInterval: TimeSpan.FromDays(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = TimeSpan.FromDays(30)
});
我检查的cookie登录后,它是真实的,过期是30天,但几分钟后,/当我试图再次访问该网站时,登录状态消失。任何想法为什么?
用户在数据库的'SecurityStamp'字段中是否有任何值? – trailmax