文章參考:http://www.javashuo.com/article/p-mltlitps-hd.htmlhtml
1.解決辦法是在web.config增長以下節點到<configuration>下web
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="1024000000" />
</webServices>
</scripting>
</system.web.extensions>json
2.框架
1 RootObject ScriptDeserialize(string json) 2 { 3 //JSON 字符串的最大長度。 默認長度爲 2097152 個字符,等同於 4 MB 的 Unicode 字符串數據。 4 //js.MaxJsonLength = 2097152; 5 js.MaxJsonLength = 10240000; 6 JavaScriptSerializer jsseria = new JavaScriptSerializer(); 7 jsseria.MaxJsonLength = Int32.MaxValue; 8 return js.Deserialize<RootObject>(json); 9 }
提示:不能直接修改json的大小,由於MVC框架內置的JsonResult代碼中,在使用JavaScriptSerializer時,都是採用的默認值,沒有從maxJsonLength讀取值,即忽略了這個配置spa
因此咱們要重寫一下,覆蓋原有的配置。code