title: Request.Files is always null
body: <p>I'm writing a C# ASP.Net MVC application for client to post files to other server. I'm using a generic handler to handle posted files from client to server. But in my handler, System.Web.HttpContext.Current.Request.Files always empty (0 count).</p>
  
  <p>Form Code:</p>
  
  <pre><code>@model ITDB102.Models.UploadFileResultsModels
  @{
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  &lt;div&gt;
      &lt;h1&gt;Upload File&lt;/h1&gt;
      &lt;form id="file-form" action="/Files/UploadFile" method="post" data-ajax="false" enctype="multipart/form-data"&gt;
          &lt;div&gt;&lt;input type="file" id="FilePath" name="FilePath"/&gt;
          &lt;button type="submit"&gt;Send File&lt;/button&gt;&lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  @section scripts{
      &lt;script src="~/Scripts/jquery-1.10.2.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
          // Variable to store your files
          var files;
          var form = document.getElementById('file-form');
  
          // Add events
          $('input[type=file]').on('change', prepareUpload);
  
          // Grab the files and set them to our variable
          function prepareUpload(event) {
              files = $('#FilePath').get(0).files;
          }
  
          form.onsubmit = function (event) {
              uploadFiles(event);
          }
  
          // Catch the form submit and upload the files
          function uploadFiles(event) {
              event.stopPropagation(); // Stop stuff happening
              event.preventDefault(); // Totally stop stuff happening           
  
              // Create a formdata object and add the files
              var data = new FormData();
              if (files.lenght &gt; 0)
              {
                  data.append('UploadedFiles', files[0], file[0].name);
              }
  
              //setup request
              var xhr = new XMLHttpRequest();
              //open connection
              xhr.open('POST', '/Files/UploadFile',false);
              xhr.setRequestHeader("Content-Type", files.type);
              //send request
              xhr.send(data);
  
          }
  
      &lt;/script&gt;
  
  }
  </code></pre>
  
  <p>Handler:</p>
  
  <pre><code>/// &lt;summary&gt;
      /// Uploads the file.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      [HttpPost]
      public virtual ActionResult UploadFile()
      {
          HttpPostedFile myFile = System.Web.HttpContext.Current.Request.Files["UploadedFiles"];
  
          bool isUploaded = false;
          string message = "File upload failed";
  
          if (myFile != null &amp;&amp; myFile.ContentLength != 0)
          {
              string pathForSaving = Server.MapPath("~/Uploads");
              if (this.CreateFolderIfNeeded(pathForSaving))
              {
                  try
                  {
                      myFile.SaveAs(Path.Combine(pathForSaving, myFile.FileName));
                      isUploaded = true;
                      message = "File uploaded successfully!";
                  }
                  catch (Exception ex)
                  {
                      message = string.Format("File upload failed: {0}", ex.Message);
                  }
              }
          }
          return Json(new { isUploaded = isUploaded, message = message }, "text/html");
      }
  
  
      #region Private Methods
  
      /// &lt;summary&gt;
      /// Creates the folder if needed.
      /// &lt;/summary&gt;
      /// &lt;param name="path"&gt;The path.&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      private bool CreateFolderIfNeeded(string path)
      {
          bool result = true;
          if (!Directory.Exists(path))
          {
              try
              {
                  Directory.CreateDirectory(path);
              }
              catch (Exception)
              {
                  /*TODO: You must process this exception.*/
                  result = false;
              }
          }
          return result;
      }
  
      #endregion
  </code></pre>
  
  <p>Please help me. Thanks.</p>