In this article I will explain with an example, how to set custom Session Timeout in ASP.Net Core (.Net Core 5).
Setting Session Timeout
In case you want to set the custom Session timeout value, then you need to set the IdleTimeout property which sets the Session timeout duration.
Note:The default Session Timeout in ASP.Net Core is 20 minutes.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
//Set Session Timeout. Default is 20 minutes.
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(45);
});
}
Downloads
Other available versions