我的Startup.cs
中有以下代码
services.AddIdentity<MasterUser, IdentityRole>(config =>
{
config.User.RequireUniqueEmail = true;
config.Cookies.ApplicationCookie.AccessDeniedPath = new PathString("/Authentication/Login");
config.Cookies.ApplicationCookie.LoginPath = new PathString("/Authentication/Login");
config.Cookies.ApplicationCookie.LogoutPath = new PathString("/Authentication/Login");
config.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromDays(36500);
config.Cookies.ApplicationCookie.SlidingExpiration = true;
})
.AddUserManager<MasterUserIdentityManager>()
.AddUserStore<MasterUserIdentityClaimStore>()
.AddEntityFrameworkStores<MasterDatabaseContext>();
ExpireTimeSpan
设置为 100 年,而SlidingExpiration
设置为 true,但应用程序会在大约 35 分钟后注销经过身份验证的用户,即使他们处于活动状态也是如此。就好像由于某种原因没有应用这些设置一样。
认为您可能也需要设置SecurityStampValidationInterval
config.SecurityStampValidationInterval = TimeSpan.FromDays(36500);;