开发者

How to access session in MVC 1.0

开发者 https://www.devze.com 2022-12-16 04:40 出处:网络
In an MVC 1.0 C# app, what\'开发者_开发知识库s the different between the following: HttpContext.Current.Session[\"MyValue\"] = \"ItsValue\";

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
0

精彩评论

暂无评论...
验证码 换一张
取 消