HttpRequest vs HttpRequestMessage vs HttpRequestBase

jumper

New Member
What are differences between these classes in ASP.NET? As I discovered there is no inheritance relationship between these classes.Below code returns an instance of \[code\]HttpRequestWrapper\[/code\] which \[code\]is a\[/code\] \[code\]HttpRequestBase\[/code\] and \[code\]has a\[/code\] \[code\]HttpRequest\[/code\]\[code\]HttpRequestMessage request = ...;HttpRequestBase reqBase = (request.Properties["MS_HttpContext"] as HttpContextWrapper).Request;// do somthing with reqBase.Cookies\[/code\]It seems like Microsoft wanted to annoy us while reaching cookies from HttpRequestMessage.Is it guaranteed that \[code\]request.Properties["MS_HttpContext"]\[/code\] will never be null?Or think that an ajax request is handled in an action of ApiController. I can reach IP of the client with two different ways.\[code\]var ip = (request.Properties["MS_HttpContext"] as HttpContextWrapper).Request.UserHostAddressvar ip = HttpContext.Current.Request.UserHostAddress\[/code\]What is the difference between these two?Or in general, I can access same request/response data such as Cookie, Header, Requestor Info etc. with different ways. When to use which? Can we say something like "if it is an ajax request, HttpRequest is not guaranteed to work properly because of lack of something so in we should use HttpRequestMessage instead"?
 
Back
Top