I am migrating an ASP.NET MVC application to ASP.NET Core MVC.
In ASP.NET MVC, I am using some Session
variables to store or get values like:
Session["UserID"] = user.UserName;
Session["Role"] = role[0].ROLE_DESCRIPTION;
ViewData["LEVEL"] = Session["LEVEL"];
But after converting, I get an error:
The name 'Session' does not exist in the current context
Also, I need to have replacement for this as well in the .cshtml
file:
var UserName = "@Session["Name"]";
Is there any other method in ASP.NET Core MVC to store or get values on those variables without changing the behavior?