i'm using an example in which i can fake the session. It's for use in a unittest of a mvc controller.
In the test i create a controller and then i do this:
FakeHttpContext httpctx = new FakeHttpContext(null,null,null,null,mSessionItems );
ControllerContext ctx2 = new ControllerContext(httpctx,new RouteData(), target);
where mSessionItems
is my session and target
is my instance of a controller
and indeed, when i'm in a controller reading this.ControllerContext.HttpContext.Session
, i have a session, great!
but.... i also read the session outside the controller, and there i use HttpContext.Current.Session
, and that is null (or actualy, the HttpContext.Current
is null).
So i wondered, what is the difference between the two?