title: MVC 5 Uploading file (POST) with one additional parameter
body: <p>I am using <a href="http://www.c-sharpcorner.com/article/upload-files-in-asp-net-mvc-5/" rel="noreferrer">this</a> simple tutorial to upload a file in my MVC5 C# VS2015 project, and without requireing additional parameters in controllers action, file gets successfuly uploaded. Here are controllers action</p>
  
  <pre><code>    [HttpPost]
      public string UploadFile(HttpPostedFileBase file)
      {
          if (file.ContentLength &lt;= 0)
              throw new Exception("Error while uploading");
  
          string fileName = Path.GetFileName(file.FileName);
          string path = Path.Combine(Server.MapPath("~/Uploaded Files"), fileName);
          file.SaveAs(path);
          return "Successfuly uploaded";
      }
  </code></pre>
  
  <p><br>
  and view's form for uploading</p>
  
  <pre><code>@using (Html.BeginForm("UploadFile", "Documents", FormMethod.Post, new { enctype = "multipart/form-data" }))
  {
      @Html.TextBox("file", "", new { type = "file" })
      &lt;input type="submit" value="Dodaj fajl" /&gt;
  }  
  </code></pre>
  
  <p>In that view, I have another variable called <code>DocumentNumber</code>, that I need to pass on to <code>UploadFile</code> action. I only guess that then header of my action would look like this: <code>public string UploadFile(HttpPostedFileBase file, int docNo)</code> if I wanted to pass that variable on, but I also don't know how to set this value in view's form. I tried adding: <code>new { enctype = "multipart/form-data", docNo = DocumentNumber }</code> without success. How do I pass <code>DocumentNumber</code> (that needs to be hidden, not visible) from my view to controller's action with post method?</p>