我发现了问题。在Starup.cs中可以找到:
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Account/Login";
options.LogoutPath = "/Account/Logout";
options.ExpireTimeSpan = TimeSpan.FromMinutes(30);
});
为了保持理智,我把它改成了:
int timeoutInMinutes = 30;
try
{
timeoutInMinutes = Int32.Parse(Configuration.GetSection("AppSettings:SessionTimeoutInMinutes").Value);
}
catch (Exception) { } // do nothing
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Account/Login";
options.LogoutPath = "/Account/Logout";
options.ExpireTimeSpan = TimeSpan.FromMinutes(timeoutInMinutes);
});
有了这个更改,如果不在appse.json中更改,登录会话现在将在30分钟后过期,否则它将使用我在appsejson中指定的值。