title: HttpRequest vs HttpRequestMessage vs HttpRequestBase
body: <p>What are differences between these classes in ASP.NET? As I discovered there is no inheritance relationship between these classes.</p>
  
  <p>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></p>
  
  <pre><code>HttpRequestMessage request = ...;
  HttpRequestBase reqBase = (request.Properties["MS_HttpContext"] as HttpContextWrapper).Request;
  // do somthing with reqBase.Cookies
  </code></pre>
  
  <p>It seems like Microsoft wanted to annoy us while reaching cookies from HttpRequestMessage.</p>
  
  <p>Is it guaranteed that <code>request.Properties["MS_HttpContext"]</code> will never be null?</p>
  
  <p>Or think that an ajax request is handled in an action of ApiController. I can reach IP of the client with two different ways.</p>
  
  <pre><code>var ip = (request.Properties["MS_HttpContext"] as HttpContextWrapper).Request.UserHostAddress
  
  var ip = HttpContext.Current.Request.UserHostAddress
  </code></pre>
  
  <p>What is the difference between these two?</p>
  
  <p>Or in general, I can access same request/response data such as Cookie, Header, Requestor Info etc. in 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 for ajax requests we should use HttpRequestMessage instead"?</p>