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