更新时间:2021-10-18 02:15:59
MVC 的会话过期由 ASP.NET Core 通过 cookie 提供,独立于 ASP.NET 零.
Session expiry for MVC is provided via cookie by ASP.NET Core, independent of ASP.NET Zero.
在Startup.cs中的IdentityRegistrar.Register
之后调用ConfigureApplicationCookie
:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// ...
IdentityRegistrar.Register(services); // No change
AuthConfigurer.Configure(services, _appConfiguration); // No change
services.ConfigureApplicationCookie(o =>
{
o.ExpireTimeSpan = TimeSpan.FromHours(1);
o.SlidingExpiration = true;
});
// ...
}
来自 ASP.NET Core v2.2.8 CookieAuthenticationOptions.cs#L30-L36:
public CookieAuthenticationOptions()
{
ExpireTimeSpan = TimeSpan.FromDays(14);
ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
SlidingExpiration = true;
Events = new CookieAuthenticationEvents();
}
ASP.NET Zero v7.2.0+ 提供:
ASP.NET Zero v7.2.0+ provides: