title: When I try to upload a file in ASP.NET MVC, it shows as null
body: <p>For some reason the paramater <code>OriginalLocation</code> is always <code>null</code> in the following code. What am I doing wrong?</p>
  
  <h3>Controller:</h3>
  
  <pre><code> [HttpPost]
   public ActionResult File(HttpPostedFileBase OriginalLocation, FileModel model)
   {
       byte[] binaryData = null;
       if (OriginalLocation != null &amp;&amp; OriginalLocation.ContentLength &gt; 0)
       {
           binaryData = new byte[OriginalLocation.ContentLength];
           OriginalLocation.InputStream.Read(binaryData, 0,
                            OriginalLocation.ContentLength);
           if (model.UploadFile(OriginalLocation))
           {
               return RedirectToAction("Profile", "Account");
           }
       }
   return View();
   }
  </code></pre>
  
  <h3>View:</h3>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master" Inherits="System.Web.Mvc.ViewPage&lt;NISE.Web.TestForum.Models.File.FileModel&gt;" %&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server"&gt;
  Find upload
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"&gt;
  
  &lt;% using (Html.BeginForm("File", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
     { %&gt; 
  &lt;%--&lt;form enctype="multipart/form-data" method="post" action="/File/File"&gt;--%&gt;
  
        &lt;input type="file" name="OriginalLocation" id="OriginalLocation"  /&gt;
  
      &lt;input type="submit" value="Upload" /&gt;
  
  &lt;%--&lt;/form&gt;--%&gt;
  &lt;%} %&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <h3>Model:</h3>
  
  <pre><code>public bool UploadFile(HttpPostedFileBase OriginalLocation)
      {
          if (OriginalLocation != null)
          {
              var filename = Path.GetFileName(OriginalLocation.FileName);
              OriginalLocation.SaveAs(@"C:\" + filename);
              return true;
          }
          return false;
      }
  </code></pre>