Skip to content

AspNetSessionId Layout Renderer

Rolf Kristensen edited this page Jan 1, 2022 · 1 revision

ASP.NET Session ID.

Platforms Supported: All

Configuration Syntax

${aspnet-sessionid}

Enable sessions in ASP.NET Core

Add line to ConfigureServices() in Startup.cs

public void ConfigureServices(IServiceCollection services)
{
     ...
    services.AddMvc();
    services.AddSession(); // After AddMvc()
    services.AddHttpContextAccessor();
     ...
}

Add line to Configure() in Startup.cs

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
     ...
    app.UseSession();  // Before UseMvc()
    app.UseMvc();
     ...
}

See also Configure session state

Clone this wiki locally