hi,
i am trying to access Session variables in the constructor of a controller and ControllerContext it seems is always null.
When is the earliest the session variables are available?
thanks!
Edit: Example:
in one controller:
public HomeController()
{
MyClass test = (MyClass)ControllerContext.HttpContext.Session["SessionClass"];
//ControllerContext always null
}
when debugging, controllercontext is ALWAYS null. In the controller whose actionresult redirects to this controller, i have:
Session["SessionClass"] = class;
MyClass test = (MyClass )ControllerContext.HttpContext.Session["SessionClass"];
// this works fine! i can get varibale from session
return RedirectToAction("Index", "Home");
So, at what point is ControllerContext actually set? When can I access session variables?