views:

35

answers:

2

In an MVC 1.0 C# app, what's the different between the following:

HttpContext.Current.Session["MyValue"] = "ItsValue";

and

Session["MyValue"] = "ItsValue";
+1  A: 

Session["MyValue"] is accessing a property of the ViewPage object. I you're trying to get to the session from another class which isn't a ViewPage, you'd use HttpContext.Current.Session["MyValue"];

Charlie
A: 

They are equivalent in that they reference the same object.

HttpContext.Current.Session == this.Session
SoloBold