I know this call works, because I can see it in the xhr headers when debugging. However, the data never seems to hit the controller and I can't figure out why. My ASP.Net skills are pretty limited so I'll post everything I've done.
JS:
var data = JSON.stringify(myObj)
$.ajax({
url: '/Things/UploadInfo',
type: 'POST',
data: data,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
crossDomain: true,
cache: false,
processData: false,
success: function (data) {
console.log('success')
},
error: function() {
console.log('error')
}
});
string data keeps returning null
[System.Web.Http.HttpPost]
public JsonResult UploadInfo(string data)
{
InfoModel someInfo = new InfoModel();
return Json(new { status = "success" });
}
InfoModel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace ProjectName.Models
{
public class InfoModel
{
public class Attr
{
public string name { get; set; }
public string age { get; set; }
public string sex { get; set; }
}
}
}