我得到在POST请求JSON对象(即NewDataSet),见下文(萤火虫要求对象)图像JSON对象...无法读取POST请求“ASP.net”
我怎样才能得到这个对象在服务器端?
感谢上JSON.net
我得到在POST请求JSON对象(即NewDataSet),见下文(萤火虫要求对象)图像JSON对象...无法读取POST请求“ASP.net”
我怎样才能得到这个对象在服务器端?
感谢上JSON.net
Xtremist
结账信息,我将创建一个服务器端对象匹配您正在发布到服务器的JSON对象。
public class DataPackage
{
public string CostType {get; set;}
public string CostName {get; set;}
public bool isEditable {get; set;}
...
}
在你的web服务,你可以设置服务的定义是这样的:
[System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json, XmlSerializeString = false)]
public void MyWebservice(DataPackage NewDataSet) {
...
}
你需要告诉您正在发送json的客户端发布脚本:
contentType: 'application/json'
如果我请记住,这将告诉ASP.NET将您的JSON对象反序列化为.NET类。
我认为它已经在这里得到解答:http://stackoverflow.com/questions/4367022/working-with-json-on-the-server-side-in-asp-net-and-c – Prashant