ASP.NET Core MVC
Session expiry for MVC is provided via cookie by ASP.NET Core, independent of ASP.NET Zero.
Call ConfigureApplicationCookie
after IdentityRegistrar.Register
in Startup.cs:
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;
});
// ...
}
The defaults from 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 (for ASP.NET Core)
ASP.NET Zero v7.2.0+ provides: