更新时间:2022-05-26 01:19:44
MVC的会话过期由ASP.NET Core通过cookie提供,独立于ASP.NET Zero.
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 CookieAuthenticationAuthentications.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: