title: ASP.NET MVC3 RAZOR: File Upload gives zero as file count
body: <p>I need to upload multiple files into web server using MVC3 with RAZOR. I have the following code. In the controller, I am getting zero as the file count. How to correct it to get the actual number of files being uploaded and to get the content?</p>
  
  <pre><code>public class MyFileController : Controller
  {
  
      public ActionResult MyFileProcessActionTest()
      {
          return View();
      }
  
      [HttpPost]
      public ActionResult MyFileProcessActionTest(IEnumerable&lt;System.Web.HttpPostedFileBase&gt; files)
      {
  
          int fileCount = files.Count&lt;System.Web.HttpPostedFileBase&gt;();
          return RedirectToAction("Index");
      }
  }
  </code></pre>
  
  <p>VIEW</p>
  
  <pre><code>@{
  ViewBag.Title = "MyFileProcessActionTest";
  }
  
  &lt;h2&gt;MyFileProcessActionTest&lt;/h2&gt;
  
  @using (Html.BeginForm())
  {
  
  &lt;input type="file" name="files" id="file1" /&gt;
  &lt;input type="file" name="files" id="file2" /&gt;
  
  &lt;input type="submit"  /&gt;
  
  }
  </code></pre>
  
  <p>READING:</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/2491230/binding-httppostedfilebase-using-ajax-beginform">Binding HttpPostedFileBase using Ajax.BeginForm</a></p></li>
  <li><p>ASP.NET MVC Uploading and Downloading Files
  <a href="http://www.mikesdotnetting.com/Article/125/ASP.NET-MVC-Uploading-and-Downloading-Files" rel="nofollow noreferrer">http://www.mikesdotnetting.com/Article/125/ASP.NET-MVC-Uploading-and-Downloading-Files</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/71944/how-do-i-validate-the-file-type-of-a-file-upload">How do I Validate the File Type of a File Upload?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/4784225/mvc-3-file-upload-and-model-binding">MVC 3 file upload and model binding</a></p></li>
  </ol>