Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between HttpContext.Current.Response/Request And Page.Request/Response

Tags:

c#

asp.net

Please, can you explain me what is the difference between HttpContext.Current.Response/Request And Page.Request/Response.

Thank you

like image 931
Sebastien Robert Avatar asked Jul 07 '11 17:07

Sebastien Robert


People also ask

What is the difference between HttpContext current items and HttpContext current session in asp net?

Item” data is live for single HTTP request/Response where HttpContext. Current. Session data is live throughout user's session.

What is the difference between session and HttpContext current session?

There is no difference. The getter for Page. Session returns the context session.

What is HttpContext HTTP request and Httpresponse?

HttpRequest is a subset of HttpContext . In other words, the HttpContext includes the response, the request, and various other data that's not relevant to a specific request or response; such as the web application, cached data, server settings and variables, session state, the authenticated user, etc.

What does HttpContext current do?

The static property Current on the HttpContext class can be useful whenever the flow of control leaves the code in your Page derived web form. Using this property you can reach out and magically grab the current Request, Response, Session, and Application objects (and more) for the request you are servicing.


1 Answers

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.

like image 70
SLaks Avatar answered Oct 23 '22 19:10

SLaks