title: How to Post file along with form data to MVC controller using Ajax?
body: <p>I am trying to post file along with other form data to MVC controller using jquery Ajax.</p>
  
  <p><strong>jQuery Ajax call</strong></p>
  
  <pre><code>function SaveStundent () {
      var formData = new FormData();
  
      var file = document.getElementById("studImg").files[0];
      formData.append("studImg", file);
  
      var studentDetails = {
      Name: $('#txtName').val().trim()
      };
  
      formData.append("studentDetails", studentDetails);
  
          $.ajax({
          type: "POST",
          url: "@(Url.Action("CreateStudent", "Student"))",          
          data: formData,
          processData: false,
          contentType: false,
              success: function (response) {
              }
          });
  }
  </code></pre>
  
  <p><strong>MVC Controller</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult CreateStudent(Student studentDetails)
  {
  // ...
  }
  </code></pre>
  
  <p><strong>Student Model</strong></p>
  
  <pre><code>public class Student
  {
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>Though I was able to get the file in the Request, the <code>studentDetails</code> parameter is always null in MVC controller. </p>