FIX: ”The length of the string exceeds the value set on the maxJsonLength property” error message when you access an ASP.NET 3.5 web form

Applies to: Microsoft .NET Framework 3.5 Service Pack 1

Symptoms


Consider the following scenario:

  • You have an ASP.NET web application that uses the Microsoft .NET Framework 3.5.
  • Your application has a page that uses the UpdatePanel control.
  • You access the ASP.NET web form, and the UpdatePanel control tries to post back data that is more than 2.5 megabytes (MB).
In this scenario, the ASP.NET web form is not displayed correctly. Additionally, you receive an error message in the web browser that resembles the following:
Error: Sys.WebForms.PageRequestManagerServerErrorException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Note This issue occurs even if you set the maxJsonLength property to a large value in the Web.config file.

Cause


This issue occurs because of a design limitation in the System.web.extensions.dll file. Specifically, the JavaScriptSerializer constructor sets a hard limit to the maximum value of the maxJsonLength property. Sometimes, the maximum value is not large enough. This causes the issue that is described in the "Symptoms" section.

Resolution


Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites

To apply this hotfix, you must have .NET Framework 3.5 SP1 installed on a computer that is running one of the following operating systems:
  • Windows XP
  • Windows Server 2003
  • Windows Vista
  • Windows Server 2008

Restart requirement

You may have to restart the computer after you apply this hotfix if any of the affected files are being used when you install the hotfix. To avoid restarting the computer, shut down any ASP.NET website before you install the hotfix.

Hotfix replacement information


This hotfix does not replace any other hotfixes.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
For all supported x86-based versions of the .NET Framework 3.5
File nameFile versionFile sizeDateTimePlatform
System.web.extensions.dll3.5.30729.45591,277,95224-Jun- 201008:47x86
For all supported x64-based versions of the .NET Framework 3.5
File nameFile versionFile sizeDateTimePlatform
System.web.extensions.dll3.5.30729.45591,277,95224-Jun-201013:25x64
For all supported IA-64-based versions of the .NET Framework 3.5
File nameFile versionFile sizeDateTimePlatform
System.web.extensions.dll3.5.30729.45591,277,95224-Jun-201017:34IA-64

Post-installation instructions

After you apply the hotfix, add the following element to the Web.config file, and then specify a bigger value for the maximum length of the script.
<appSettings>
<add key=”aspnet:UpdatePanelMaxScriptLength” value=”<value>” />
</appSettings>
To work around this problem, use the Gacutil.exe command to install the interop assembly in the global assembly cache.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

References


For more information about the UpdatePanel control, visit the following Microsoft Developer Network (MSDN) website: For more information about the jsonSerialization element, visit the following MSDN website: