[Solved] ASP.Net MVC JSON Error: The length of the string exceeds the value set on the maxJsonLength property

paulrajmca
 
on Jul 15, 2021 11:57 PM
789 Views

Hi Developers,

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

I got the Above mentioned error when i get base64 string length of 2974208 Jquery Ajax call on following line 

"var Retdata = JSON.parse(response.ResponseContent);"

Added in Web.Config : 

<add key="JSONMAXJSONLENGTH" value="2147483644" />
<add key="aspnet:MaxJsonDeserializerMembers" value="2147483644" />
<add key="aspnet:UpdatePanelMaxScriptLength" value="2147483644" />
<add key="aspnet:MaxJsonDeserializerMembers" value="2147483644"/>

 

<httpRuntime targetFramework="4.5" enableVersionHeader="false" executionTimeout="1"  maxRequestLength="2000000000" maxQueryStringLength = "12288" maxUrlLength="12288"/>

If anyone know the solution for this problem kindly help me to done this task.

Thanks & Regards

Paul.S

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 15, 2021 11:59 PM
on Jul 16, 2021 12:01 AM

Hi paulrajmca,

The solution to this problem is to set a higher value of maxJsonLength property through Web.Config configuration using the system.web.extensions section as shown below.

<system.web.extensions>
    <scripting>
        <webServices>
            <jsonSerialization maxJsonLength="2147483644" />
        </webServices>
    </scripting>
</system.web.extensions>