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 cachedHttpSessionState
reference. - The
Page
method will throw if session state is not enabled, whileHttpSessionState.Session
just returns whatever is in the "AspSession" bucket of itsItems
collection.
Yup; they refer to the same instance.
There is no difference between the two.
精彩评论