如何在 MVC 3 操作中接收 JSON 作为模型(包含字典)?
浏览器端:将 JSON 发布到 MVC3 操作:
UpdateData :
{
Id: 88991,
Changes:
{
X:5,
Y:6
}
}
服务器端:
public class UpdateDataModel
{
public int Id {get;set;}
public IDictionary<string, string> Changes {get;set;}
}
public ActionResult SaveUpdateData(UpdateDataModel updateData)
{
// updateData.Id should be 88991
// updateData.Changes should be a dictionary containing X:5, Y:6
}