views:

78

answers:

1

hi,

i am trying to store an object in session..

in one controller, i create the object and put it in session.

MyObject _o = new MyObject();
Session["MyObject"] = _o;
MyObject _oo = (MyObject)Session["MyObject"]; // added for testing purposes, is not null

i can retrieve the object from session just fine from within same controller.

then i redirect to an action method on another controller, and in a base controller i try to access ControllerContext.HttpContext.Session and it is always null.

if(_obj == null)
{
    _obj = (MyObject)Session["MyObject"]; // always null
}

any ideas why?

thanks :-)

+1  A: 

When access Session object?

HttpContext initialized after Controller.Initialize().

takepara