我正在使用JSON JavaScriptSerializer序列化和反序列化过程中在增加JSON响应maxJsonLength 4
“错误加载一个大的JSON响应形式服务器当在剃刀视图发动机MVC4(.NET 4.5)应用以下错误字符串的.The长度超过在@ Html.Raw(Json.Encode(jsondata)”
我已经在我的web.config设置MaxJsonLength财产试图在maxJsonLength属性设置的值:
configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
在发送JSON响应的同时在服务器端尝试了下面的内容。
return new JsonResult()
{
Data = data,
ContentType = contentType,
ContentEncoding = contentEncoding,
JsonRequestBehavior = behavior,
MaxJsonLength = Int32.MaxValue
};
还试过列出的解决方案野兔:http://brianreiter.org/2011/01/03/custom-jsonresult-class-for-asp-net-mvc-to-avoid-maxjsonlength-exceeded-exception/。但没有在视图中使用下面的代码为我工作:(
能否有人建议我如何避免这种错误,或者如何提高杰森响应最大长度?
您是否尝试过的解决方案建议在这里的http:// stackoverflow.com/questions/6860053/json-maximum-length-pro blem-with-asp-net? – 2013-03-08 06:54:01
是的,我也厌倦了这个解决方案。但没有成功 – Nabeel 2013-03-08 09:56:54
'我也厌倦了这个解决方案'漂亮弗洛伊德滑:-) – 2017-06-22 11:56:21