正如标题所说,我希望在C#后端操作从客户端AJAX POST请求接收的JSON。这是我的代码:
客户端:
var myData = { Name: "tyler", Age: 3 };
var moreData = {
documentName: "Doc-109",
attachments: {
name: "Attachment 11"
}
};
$.post('/NMISProduct/Index', { myData: myData, moreData: moreData }, function(returnedData) {
console.log(returnedData);
}, 'json');
C#后端:
[HttpPost]
public ActionResult Index(string myData, string moreData)
{
//I want to return myData.Name + moreData.attachments.name in JSON format - How do I do this?
}
我该怎么做?