HttpRequest represents http client on server as per http://msdn.microsoft.com/en-us/library/system.web.httprequest.aspx it "Enables ASP.NET to read the HTTP values sent by a client during a Web request."
It was my understanding that HttpContext also does the same. As per MSDN http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx it is "Encapsulates all HTTP-specific information about an individual HTTP request."
What we need to class for this ? How are they different and which should be used when ?
I am not able to figure out what is difference between them ? Can you please guide and help.
Thanks
Best Answer
HttpRequest
is a subset ofHttpContext
. In other words, theHttpContext
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.For example:
I think if you dig around the APIs of each, you'll quickly understand how things are organized.