1
Reply

Can we enable Session in ASP.NET Core ? if yes then how we can enable Session in ASP.NET Core ?

Arvind Yadav

Arvind Yadav

3y
4.5k
1
Reply

Can we enable Session in ASP.NET Core ?
if yes then how we can enable Session in ASP.NET Core ?

    To enable session in ASP.NET Core you can install Microsoft.AspNetCore.Session package.
    With this done you can configure it as follows

    1. public void ConfigureServices(IServiceCollection services){
    2. services.AddMvc();
    3. services.AddSession(options => {
    4. options.IdleTimeout = TimeSpan.FromMinutes(60);
    5. });
    6. }

    You can access session with HttpContext.Session