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

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

By Arvind Yadav in .NET Core on Feb 12 2022
  • Bohdan Stupak
    Feb, 2022 17

    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

    • 3


Most Popular Job Functions


MOST LIKED QUESTIONS