title: ASP.NET MVC 3 - File Upload
body: <p>I have an ASP.NET MVC 3 application. I need to implement a file uploader action within it. For some reason, when I post my form, the Request.Files collection is empty. I have been able to confirm this by setting a breakpoint. So I know that I'm reaching the action. However, I can't figure out why the Request.Files collection is empty. Here are my relevant HTML, AreaRegistration, and Controller snippets.</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;form action="/files/upload/uniqueID" method="post" enctype="multipart/form-data"&gt;
      &lt;div&gt;Please choose a file to upload.&lt;/div&gt;
      &lt;div&gt;&lt;input id="fileUpload" type="file" /&gt;&lt;/div&gt;
  
      &lt;div&gt;&lt;input type="submit" value="upload" /&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>MyAreaRegistration.cs</strong></p>
  
  <pre><code>context.MapRoute(
    "FileUpload",
    "files/upload",
    new { action = "UploadFile", controller = "Uploader" }
  );
  </code></pre>
  
  <p><strong>UploaderController.cs</strong></p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Post)]
  public ActionResult UploadFile(int uniqueID)
  {
    foreach (string file in Request.Files)
    {
      // I never get here :(
    }
  
    return View();
  }
  </code></pre>
  
  <p>I have not made any changes to the default web.config file. Is there some setting I need to add? I can't figure out why the Request.Files collection would be empty. Can someone please help me? </p>
  
  <p>Thank you so much!</p>