I have a View which is using
Session["Something"] = 1;
And I have a class inside a class library project that tries to get this value from the session using
HttpContext.Current.Session["Something"]
But it retuns null
.
public ActionResult Index()
{
Session["Something"] = 1;
var fromLib = (new MyLibClass()).GetSession("Something"); // null
var fromHere = Session["Something"]; // 1
}
// Class library project
public object GetSession(string key)
{
return HttpContext.Current.Session[key];
}
How can I get the value from the session? Or is there a way to save a value and retrieve in another place (without database or system files)