问题:
使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过了为 maxJsonLength 属性设置的值。
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="1024000000" />
</webServices>
</scripting>
</system.web.extensions>
这个方法测试了没有效果。
*上找到答案
public ContentResult GetOrderList()
{
try
{
IList<OrderAll> list = new List<OrderAll>();
return new ContentResult { Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(UnifyResponse.ReturnFun(list)), ContentType = "application/json"
}; //return this.Json(UnifyResponse.ReturnFun(list));
}
catch (Exception ex)
{
return new ContentResult
{ Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(UnifyResponse.ThrowError(ex)),
ContentType = "application/json"
};
//return this.Json(UnifyResponse.ThrowError(ex));
}
}