# Syntax for including maxJsonLength in a standalone web.config for a Sharepoint Farm solution?

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"?>
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="10000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>


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?