We encountered the following error in Javascript in a Sharepoint project:

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

Even though we've set javascriptSerializer.MaxJsonLength = Int32.MaxValue; in the C#.NET code, it seems this setting:

<jsonSerialization maxJsonLength="5000000">

in the global web.config file (which is located at C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config) is being the bottleneck. The error disappears when the maxJsonLength is set to a larger value like 10M this global web.config file.

However, we'd ideally like this setting to be placed in a project-local web.config file, which we added in the Layouts\<project-name>\ path, with the contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <jsonSerialization maxJsonLength="10000000"/>

However, this doesn't seem to work. No matter what the value for maxJsonLength in this file, the error still pops up.

My question is if the syntax in the project-local web.config is correct, or if we're missing any markup or xml attributes. Also, is there a different path for including this file other than in Layouts\<project-name>\? Why is the solution not picking up the setting from this file?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.