How to access session in MVC 1.0
In an MVC 1.0 C# app, what'开发者_开发知识库s the different between the following:
HttpContext.Current.Session["MyValue"] = "ItsValue";
and
Session["MyValue"] = "ItsValue";
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"];
They are equivalent in that they reference the same object.
HttpContext.Current.Session == this.Session
精彩评论