Jquery ajax post request is posting null json object to mvc controller. any idea why this could be?
Cheers
Here is my model
public class CommentModel
    {
       public string EmailAddress { get; set; }
       public string Name { get; set; }
       public int ActivityId { get; set; }
       public string CommentText { get; set; }
    }
Controller
 [HttpPost]
        public ActionResult Index(CommentModel commentModel)
        {
            int i = commentModel.ActivityId;
            string k = commentModel.CommentText;
          return View();
        }
JQuery
$("#CommentForm").submit(function () {
        var formDataAsJson = GetFormDataAsJson();
        $.ajax({
            url: $(this).attr("action"),
            dataType: 'json',
            type: "POST",
            data: JSON.stringify({ commentModel: formDataAsJson }),
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                $("#commentsection").append(data);
            }
        })
    });
function GetFormDataAsJson() {
    var emailInput = $("#InputEmailAddress").attr("value");
    var name = $("#InputName").attr("value");
    var comment = $("#some-textarea").attr("value");
    var activityid = parseInt($("#ActivityID").attr("value"));
    var formObject = {
        EmailAddress: emailInput,
        Name: name,
        ActivityId: activityid,
        CommentText:comment
    }
    return formObject;
}
 
     
     
     
    