title: How to receive a HttpRequest into an MVC 3 controller action?
body: <h2>Current Solution</h2>
  
  <p>So I have something very similar to </p>
  
  <pre><code>[HttpPost]
      public ActionResult Upload()
      {
          var length = Request.ContentLength;
          var bytes = new byte[length];
  
          if (Request.Files != null )
          {
              if (Request.Files.Count &gt; 0)
              {
                  var successJson1 = new {success = true};
                  return Json(successJson1, "text/html");
              }
          }
  ...
          return Json(successJson2,"text/html");
      }
  </code></pre>
  
  <h2>Unit testable solution?</h2>
  
  <p>I want something like this:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Upload(HttpRequestBase request)
  {
      var length = request.ContentLength;
      var bytes = new byte[length];
  
      if (request.Files != null )
      {
          if (request.Files.Count &gt; 0)
          {
              var successJson1 = new {success = true};
              return Json(successJson1);
          }
      }
  
      return Json(failJson1);
  }
  </code></pre>
  
  <p>However this fails, which is annoying as I could make a Mock from the base class and use it.</p>
  
  <h2>Notes</h2>
  
  <ul>
  <li>I am aware this is not a good way to parse a form/upload and would
  like to say other things are going on here (namely that this upload
  can be a form or an xmlhttprequest - the action does not know which).</li>
  <li>Other ways to make "Request" unit testable would also be awesome.</li>
  </ul>