In this article I will explain with an example, how to set custom Session Timeout in ASP.Net Core (.Net Core 2).
Note: For enabling and configuring Session in ASP.Net Core (.Net Core 2), please refer my article .Net Core 2: Enable Session in ASP.Net Core.
 
 

Setting Session Timeout

In case you want to set the custom Session timeout value, you will 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);
    });
}
 
.Net Core 2: Set custom Session Timeout in ASP.Net Core
 
Note: For more details on using Session in ASP.Net Core (.Net Core 2), please refer my article .Net Core 2: Using Session in ASP.Net Core.
 
 

Downloads



Other available versions