我使用telerik網格來顯示來自sql db的數據...當我顯示超過3500行時,它會返回:使用JSON JavaScriptSerializer進行序列化或反序列化時出現錯誤。字符串的長度超過maxJsonLength屬性中設置的值。Telerik MVC Grid - 多個數據行結果
無處不在互聯網和Telerik Troubleshooting manual也寫道,原因是編輯web.config。它並沒有幫助我...我試着返回這樣的數據:
JavaScriptSerializer serializer = new JavaScriptSerializer { MaxJsonLength = 536870912, RecursionLimit = 100 };
return new ContentResult()
{
Content = serializer.Serialize(data),
ContentEncoding = Encoding.UTF8
};
當我作爲ContentResult返回數據,過濾和排序停止工作。
我嘗試這個解決方案也:http://anyrest.wordpress.com/2011/09/27/large-json-result-for-teleriks-mvc-grid/並沒有幫助我......
這是從我的控制器代碼:
[GridAction, POST("GridData")]
public ActionResult _Index()
{
var data = GetExclusionsDataCollection();
return View(new GridModel { Data = data });
}
謝謝, 大衛