title: Access form data in C# controller from AJAX post
body: <p>I am sending form data to a c# controller using AJAX, however I don't know how to access the data inside the controller. I am trying to pass the form data into the controller as a Person object but I am just returning system.Models.Person. I am new to C# so any help would be greatly appreciated, thanks a lot.</p>
  <p>Javascript</p>
  <pre><code>$('#myForm').submit(function(e){
      e.preventDefault();
      const formData = new FormData(e.target);
      $.ajax({
          url: '/Home/GetFormData',
          type: 'POST',
          data: {formData: formData},
          success: function(resultData){
              console.log(resultData)
          },
          error: function(){
              //do something else
          }
      })
  }
  </code></pre>
  <p>Model</p>
  <pre><code>public class Person 
  {
      public string name { get; set; }
      public string age { get; set; }
  }
  </code></pre>
  <p>Controller</p>
  <pre><code>public string GetFormData(Person formData)
  {
      string name = formData.name.ToString();
  
      return name;
  
  }
  </code></pre>