I have a ASP.Net MVC 5 web application and I want to set a variable in the session so that I can access it later. As I am a beginner I don't know how to achieve it. Below is what I have tried
clsUser user = mdlUser.GetUserForSession();
System.Web.HttpContext.Current.Session["MyValue"] = user.SessionID; // user.SessionID is an integer
int x = System.Web.HttpContext.Current.Session["MyValue"] as int; // Access
But I get error as Error as
The as operator must be used with a reference type or nullable type ('int' is a non-nullable value type)
SO LINK REFERRED