MVC应用程序到期应用程序Cookie

时间:2017-05-24 08:43:20

标签: c# asp.net-mvc asp.net-identity asp.net-core-mvc

我的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分钟后注销经过身份验证的用户,即使它们处于活动状态也是如此。就好像这些设置由于某种原因而未应用。

1 个答案:

答案 0 :(得分:1)

认为您可能还需要设置SecurityStampValidationInterval

config.SecurityStampValidationInterval = TimeSpan.FromDays(36500);;