Rhy*_*ens 10 c# remember-me asp.net-mvc-5 asp.net-identity-2
我在我的MVC5应用程序中使用Identity 2.1.我将PasswordSignInAsync的isPersistent属性设置为true以启用"记住我":
var result = await SignInManager.PasswordSignInAsync(model.Username,
model.Password,
true,
shouldLockout: false);
Run Code Online (Sandbox Code Playgroud)
但是,如果我一夜之间保持登录状态,那么当我在早上刷新页面时,它会将我退出,我必须再次登录.在用户手动注销之前,如何防止自动注销?
它与身份使用的Cookie身份验证有关吗?我真的不了解Startup.Auth.cs中设置的CookieAuthenticationOptions.
new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator
.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user)
=> user.GenerateUserIdentityAsync(manager))
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12098 次 |
| 最近记录: |