Changing maxJsonLength Property

Discussion in 'ASP.NET / ASP.NET Core' started by threeJB, Dec 4, 2013.

  1. Hello,
    I am getting the following error when loading strings from a .xml file:

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

    Do you know how to modify the maxJsonLength property? It seems that the web.config file (attached) needs to modified, but I cannot seem to find the correct way to do so via the DiscountASP Knowledge Base or by searching the internet.

    I have found several posts like this one:
    http://stackoverflow.com/questions/...imited-length-for-maxjsonlength-in-web-config

    The error message is the same, but when I attempt to set the property, I get the following:

    <sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35, maxJsonLength=2147483647"requirePermission="false"allowDefinition="Everywhere"/>

    Same error.

    <sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"requirePermission="false"allowDefinition="Everywhere"maxJsonLength="2147483647"/>

    HTTP Error 500.19 - Internal Server Error

    The requested page cannot be accessed because the related configuration data for the page is invalid.

    Any other ideas?

    Thanks.
     
  2. Thanks to DiscountASP support, this has been resolved. The maxJsonLength goes in a different section of the web.config file than I was trying to put it in:

    <configuration>
    ...
    <system.web.extensions>
    <scripting>
    <webServices>
    <jsonSerialization maxJsonLength="2147483647"/>
    </webServices>
    </scripting>
    </system.web.extensions>
    ...
    </configuration>
     
    martino, FrankC, mjp and 1 other person like this.

Share This Page