title: when Upload file HttpPostedFileBase through ajax mvc returns null
body: <p>I am trying to upload file and some data to a controller action via an AJAX request, however, the HttpPostedFileBase parameter is always null</p>
  
  <p>here is my cshtml</p>
  
  <pre><code>&lt;div class="modal fade" id="MyModal"&gt;
                      &lt;div class="modal-dialog"&gt;
                          &lt;div class="modal-content"&gt;
                              &lt;div class="modal-header"&gt;
                                  &lt;a href="#" class="close" data- 
      dismiss="modal"&gt;&amp;times;&lt;/a&gt;
                                  &lt;h4 id="ModalTitle"&gt;&lt;/h4&gt;
                              &lt;/div&gt;
                              &lt;div class="modal-body"&gt;
                                  @using (Html.BeginForm("EditResearch", 
      "Admin", FormMethod.Post, new { id = "form", enctype = "multipart/form- 
      data" }))
                                      {
  
  
                                      @Html.AntiForgeryToken()
  
                                      &lt;fieldset id="SubmitForm"&gt;
                                          @Html.HiddenFor(m =&gt; m.ResearchID, 
      new { @id = "ResearchID" })
  
  
                                          &lt;div class="input-field"&gt;
                                              &lt;label for="name"&gt;Journal Name     &lt;/label&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              @Html.TextBoxFor(m =&gt; 
      m.NameJournal, new { @id = "NameJournal", @class = "form-control", 
      @placeholder = "Journal Name*" })
                                          &lt;/div&gt;
  
                                          &lt;div class="input-field"&gt;
                                              &lt;label for="name"&gt;File&lt;/label&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              @Html.TextBoxFor(model =&gt;     model.ResearchFile, new { @type = "file", @name = "ResearchFile", @id
  = 
      "ResearchFile" })
  
                                              @*&lt;input name="fileresearch" 
      id="fileresearch" type="file" /&gt;*@
                                          &lt;/div&gt;
  
                                          &lt;div class="input-field"&gt;
                                              &lt;label for="name"&gt;
                                                  Abstract
                                              &lt;/label&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              @Html.TextAreaFor(model =&gt; 
      model.ResearchContents, new { @id = "ResearchContents", @class = "form-     control", @onKeyUp = "Count(this,1000)", @onChange = "Count(this,1000)",     placeholder = "Abstract", name = "name", rows
  = "6", cols = "85" })
                                          &lt;/div&gt;
  
  
  
                                          &lt;div class="form-group"&gt;
                                              &lt;a href="#" class="btn btn-block 
      btn-danger" id="SaveStudentRecord"&gt;Save&lt;/a&gt;
                                          &lt;/div&gt;
  
                                      &lt;/fieldset&gt;
  
                                  }
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
      $("#SaveStudentRecord").click(function () {
                          var data = $("#SubmitForm").serialize();
  
                          $.ajax({
                              type: "Post",
                              url: "/Admin/SaveDataInDatabase",
                              data: data,
                              //contentType: false,
                              //processData: false,
                              success: function (result) {
  
                                  if (result) {
                                      alert("Done.");
                                      window.location.href = 
      "/Admin/EditResearch";
                                      $("#MyModal").modal("hide");
                                  }
                                  else {
                                      alert("Fill Boxes");
                                      //window.location.href = 
      "/Admin/EditResearch";
                                      //$("#MyModal").modal("hide");
                                  }
  
  
  
                              }
                          })
                      })
  </code></pre>
  
  <hr>
  
  <p>here is my controller</p>
  
  <pre><code>[HttpPost]
          public JsonResult SaveDataInDatabase(ResearchBL model, 
      HttpPostedFileBase ResearchFile)
          {
              try
              {
  
                  if (Session["user"] != null)
                  {
                      ViewBag.Message = "";
                      string Err = "";
                      string userID = Session["user"].ToString();
  
                      ResearchModel researchObj = new ResearchModel();
  
                      bool Check = researchObj.SaveDataInDatabase(model, 
      userID, ResearchFile, ref Err);
  
                      ViewBag.Message = Err;
  
                      return Json(Check, JsonRequestBehavior.AllowGet);
  
                  }
                  else
                  {
                      RedirectToAction("Login", "Admin");
                      return null;
                  }
  
              }
              catch (Exception ex)
              {
                  return null;
              }
  
          }
  </code></pre>
  
  <hr>
  
  <p>here is my class ResearchModel </p>
  
  <pre><code>    public Boolean SaveDataInDatabase(ResearchBL model, string userID, 
      HttpPostedFileBase ResearchFile, ref string Err)
              {
                  var result = false;
  
                      using (ZUNew1Entities2 db = new ZUNew1Entities2())
                      {
                          if (model.ResearchID &gt; 0)
                          {
  
                              if (!string.IsNullOrEmpty(model.ResearcherName)
                              &amp;&amp; !string.IsNullOrEmpty(model.ResearchName)
                              &amp;&amp; !string.IsNullOrEmpty(model.NameJournal)
                              &amp;&amp; !string.IsNullOrEmpty(model.ResearchContents)
                              &amp;&amp; !string.IsNullOrEmpty(model.VolumeNumber)
  
                              )
                              {
                                  Research research = 
      db.Researches.SingleOrDefault(x =&gt; x.IsDeleted == false &amp;&amp; x.ResearchID 
      == 
      model.ResearchID);
  
                                  research.ResearchName = model.ResearchName;
                                  research.ResearcherName = 
      model.ResearcherName;
                                  research.NameJournal = model.NameJournal;
                                  research.VolumeNumber = model.VolumeNumber;
                                  research.ResearchContents = 
      model.ResearchContents;
  
                                  string day = "01";
                                  string cal = model.DateOfPublication + "-" + 
      day;
  
                                  research.DateOfPublication = 
      Convert.ToDateTime(cal);
  
  
                                  // Update Research File 
      ****************************
  
                                  string File;
  
                                  string uploadFile = 
      "~/UploadFile/Researcher/Files/";
  
                                  if (model.ResearchFile != null)
                                  {
  
                                      var fileName = 
      Path.GetFileName(ResearchFile.FileName);
                                      string pathURL = uploadFile + userID + 
      "_" + DateTime.Now.Hour.ToString() + "_" + 
      DateTime.Now.Minute.ToString() + 
      "_" + DateTime.Now.Second.ToString() + 
      DateTime.Now.Millisecond.ToString() + 
      ".pdf";
  
                                      var path = 
      Path.Combine(System.Web.HttpContext.Current.Server.MapPath(pathURL));
                                      ResearchFile.SaveAs(path);
  
  
                                  }
                                  else
                                  {
  
                                      research.ResearchFile = null;
  
                                  }
  
  
                                  db.Entry(research).State = 
                  EntityState.Modified;
                                  db.SaveChanges();
                                  result = true;
                                  Err = "";
                                  return true;
  
                              }
                              else
                              {
  
                                  Err = "Fill Boxes !!";
                                  return false;
  
                              }
  
                          }
                          else
                          {
  
                              Err = "";
                              result = false;
                              return false;
  
                          }
                      }
  
              }
  </code></pre>