2013-05-31 30 views
29

我目前有一個帶有PDF附件的網格。每個PDF文件的大小可以達到1MB。問題是我在「使用JSON JavaScriptSerializer的序列化和反序列化過程中錯誤。字符串的長度超過上maxJsonLength屬性設置值」所獲得的價值錯誤字符串的長度超過了maxJsonLength屬性設置的值

我已經放置在web.config以下,但問題是隻有當Kendo UI Grid需要顯示6條記錄時纔有效。

<system.web.extensions> 
    <scripting> 
     <webServices> 
     <jsonSerialization maxJsonLength = "2147483647"></jsonSerialization> 
     </webServices> 
    </scripting> 
</system.web.extensions> 
+0

可能重複(http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config) –

回答

69

基於以下鏈接:[?我可以在web.config中設置一個無限長度maxJsonLength]

MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

public ActionResult SomeControllerAction() 
{ 
    var jsonResult = Json(veryLargeCollection, JsonRequestBehavior.AllowGet); 
    jsonResult.MaxJsonLength = int.MaxValue; 
    return jsonResult; 
} 
+2

這將是很好的,他們在配置文件中設置此,所以不必在這裏添加額外的代碼。謝謝! –

+0

你好!在這裏,當我發佈json中數組列表長度超過600的請求時,我收到了超出最大長度的錯誤。我將所有數據傳遞給控制器​​。 – SPnL

相關問題