Setting the length of JSON(hockblogs.net)
submitted by
hockman(505) 3 years, 5 months ago
Hi there,
Today I got the following error message when invoking a webservice from client script:
Er is een fout opgetreden tijdens het serialiseren of deserialiseren met de JSON JavaScriptSerializer. De lengte van de tekenreeks overschrijdt de waarde die is ingesteld in de eigenschap maxJsonLength.
Or in plain old english:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
The result set is rather large and my client seems to have problems with that.
When diving into this problem, I immediately was send to http://www.asp.net/Ajax/Documentation/Live/mref/P_System_Web_Configuration_ScriptingJsonSerializationSection_MaxJsonLength.aspx. Here's what can be found at the remarks of the MaxJsonLength property:
The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods.
By default the MaxJsonLenght is 500 characters (according to my web.config file), but here it is stated that the default is 102400 characters. I'm using ASP.NET Ajax Version 1.0!
After setting this to 10000000 in my web.config file the problem was solved
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="10000000"/>
</webServices>
<scriptResourceHandler enableCompression="true" enableCaching="true"/>
</scripting>
</system.web.extensions>
|category: AJAX
|Views: 62
tags:
AJAX another
Everyones tags:
Your Tags: