Difference between HttpContext.Current.Response/Request And Page.Request/Response
Plea开发者_StackOverflow社区se, can you explain me what is the difference between HttpContext.Current.Response/Request And Page.Request/Response.
Thank you
None whatsoever.
The latter is shorthand for the former.
It's especially convenient when writing ASPX pages; because these pages inherit Page
, you can just write Request
or Response
.
Similarly, Page.Context
is short for HttpContext.Current
.
- If we take a look at the
System.Web.UI.Page
and take a look at property Request we see it retrieves the HttpContext for the request page. - Now if we look at the
HttpContext.Current.Request
we see that it "Gets or sets the HttpContext object for the current HTTP request."
So they are really just the same thing, you can just call them through different classes.
System.web.HttpContext
System.web.ui.page
The properties points to same object, there is no difference.
精彩评论