开发者

Accessing State in ASP.NET

开发者 https://www.devze.com 2023-01-17 12:19 出处:网络
Is System.Web.HttpContext.Current.Session 开发者_如何学Cthe same as System.Web.UI.Page.Session ?They do indeed refer to the same instance, but if you look at the methods in Reflector, you can se

Is

System.Web.HttpContext.Current.Session

开发者_如何学Cthe same as

System.Web.UI.Page.Session

?


They do indeed refer to the same instance, but if you look at the methods in Reflector, you can see that they behave a bit differently (in ways that are not likely to matter in most applications):

  • The call to Page.Session uses a cached HttpSessionState reference.
  • The Page method will throw if session state is not enabled, while HttpSessionState.Session just returns whatever is in the "AspSession" bucket of its Items collection.


Yup; they refer to the same instance.


There is no difference between the two.

0

精彩评论

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