Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error The length of the string exceeds the value set on the maxJsonLength property

I am currently have a grid with PDF attachment. Each PDF can have file size up to 1MB. The problem is I am getting the value "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property"

I already placed the following in the web.config but the problem is it works only if the Kendo UI Grid needs to display 6 records.

<system.web.extensions>     <scripting>       <webServices>         <jsonSerialization maxJsonLength = "2147483647"></jsonSerialization>       </webServices>     </scripting> </system.web.extensions> 
like image 443
Spidey Avatar asked May 31 '13 01:05

Spidey


People also ask

Can I set the unlimited length for MaxJsonLength property in config?

The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).

What is the max length of MaxJsonLength?

The maximum length of JSON strings. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.


1 Answers

Based on the following link:

MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

public ActionResult SomeControllerAction() {   var jsonResult = Json(veryLargeCollection, JsonRequestBehavior.AllowGet);   jsonResult.MaxJsonLength = int.MaxValue;   return jsonResult; } 
like image 176
Spidey Avatar answered Oct 24 '22 15:10

Spidey