如何使用从POST请求发送到C#的JSON?

时间:2015-06-24 19:08:27

标签: javascript c# jquery json asp.net-mvc

正如标题所说,我希望在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?
}

我该怎么做?

0 个答案:

没有答案