title: HTTP POST data not going from AJAX to C# MVC 5 Backend
body: <p>As the title states, I'm trying to send data from a Javascript frontend to my C# MVC 5 backend, and it doesn't seem to make it.  I've run through it with the debugger in Visual Studio and the data I'm trying to pass always ends up null.</p>
  
  <p><strong>Here is my front end code:</strong></p>
  
  <pre><code>var file = $("#my-file").files[0];
  file = file[0];
  var formData = new FormData();
  var MyData = {
      Name: "Form 133",
      Attachments: {
          Type: "Check"
      }
  };
  formData.append('file', file);
  $.ajax({
      type: "POST",
      url: '/NMISProduct/Index',
      contentType: false,
      processData: false,
      data: { formData: formData, MyData: MyData },
      success: function (result) {
          console.log(result);
      },
      error: function (xhr, status, p3, p4) {
          var err = "Error " + " " + status + " " + p3 + " " + p4;
          if (xhr.responseText &amp;&amp; xhr.responseText[0] == "{")
              err = JSON.parse(xhr.responseText).Message;
          console.log(err);
      }
  });
  </code></pre>
  
  <p><strong>Backend code:</strong></p>
  
  <pre><code>[HttpPost]
  public async Task&lt;JsonResult&gt; Index(MyData MyData)
  {
      Debug.WriteLine(Request.Params["MyData"]);
      Debug.WriteLine(MyData.Name);
      try
      {
          foreach (string file in Request.Files)
          {
              var fileContent = Request.Files[file];
              if (fileContent != null &amp;&amp; fileContent.ContentLength &gt; 0)
              {
                  // get a stream
                  var stream = fileContent.InputStream;
                  // and optionally write the file to disk
                  var fileName = fileContent.FileName;
                  var path = Path.Combine(Server.MapPath("~/App_Data/"), fileName);
                  using (var fileStream = System.IO.File.Create(path))
                  {
                      stream.CopyTo(fileStream);
                  }
              }
          }
      }
      catch (Exception)
      {
          return Json("Upload failed");
      }
      return Json("File uploaded successfully");
  }
  
  public class MyData
  {
      public string Name { get; set; }
      public Attachment Attachments { get; set; }
  }
  
  public class Attachment
  {
      public string Type { get; set; }
  }
  </code></pre>
  
  <p>As I stated, on the Backend <code>MyData</code> always ends up being null.  What am I doing wrong?</p>