开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜