Accessing Session object inside an Asp Core 2 View
I want to show Session in view. Is that possible? I try with this in my view <div class="content-header col-xs-12"> <h1>Welcome, @HttpContext.Session.GetString("userLoggedName")</h1> </div> But i get an error Severity Code Description Project File Line Suppression State Error CS0120 An object reference is required for the non-static field, method, or property 'HttpContext.Session' Any help, i will appreciate it. Thanks You can inject IHttpContextAccessor implementation to your view and use it to get the Session object @using Microsoft.AspNetCore.Http @inject IHttpContextAccessor