As you can see, I have set the MaxJsonLength to a huge number, but I am STILL getting a "Maximum Length exceeded" error. This happens in both GET and POST scenarios. Also, my setting in the web.config file:
<
jsonSerialization
maxJsonLength="999"/>
is completely ignored! :( Finally, I know for a fact that my list (IndustryList) is not THAT large. Does anyone know what is happening here?
Thanx!
J'son
atlas javascript webservices complextypesajax webserviceJSONweb serviceajaxajax v1.0web service ajax
I know you already got it working, but just to explain how it works...
If you're using the JavaScriptSerializer class programmatically, you can set the MaxJsonLength property. But the only way to set the maximum length for invoking web methods from client script is through the web.config file.
And that section in the web. config looks like this...
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a
custom converter -->
<jsonSerialization maxJsonLength="500000">
<!--<converters>
<add name="ConvertMe"
type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>-->
</jsonSerialization>
<!-- Uncomment this line to enable the authentication service.
Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To
allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add
each property name to the readAccessProperties and
writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true"
enableCaching="true" />
-->
</scripting>
</system.web.extensions>
JCannelos
Member
8 Points
7 Posts
JSON "Maxium length exceeded"
Mar 24, 2007 12:12 AM|LINK
Guys,
I have what I hope is a simple problem. I am calling a simple web service in my project called FilterService. It has one method:
[
WebMethod][System.Web.Script.Services.
ScriptMethod(UseHttpGet=true)] public string GetIndustries(){
SetCacheHeaders();
JavaScriptSerializer serializer = new JavaScriptSerializer();serializer.MaxJsonLength = 500000000;
return serializer.Serialize(CachedLists.IndustryList);}
As you can see, I have set the MaxJsonLength to a huge number, but I am STILL getting a "Maximum Length exceeded" error. This happens in both GET and POST scenarios. Also, my setting in the web.config file:
<
jsonSerialization maxJsonLength="999"/>is completely ignored! :( Finally, I know for a fact that my list (IndustryList) is not THAT large. Does anyone know what is happening here?
Thanx!
J'son
atlas javascript webservices complextypes ajax webservice JSON web service ajax ajax v1.0 web service ajax
J'son
alesha911
Member
161 Points
42 Posts
Re: JSON "Maxium length exceeded"
Mar 24, 2007 12:59 AM|LINK
Senior Consultant
JCannelos
Member
8 Points
7 Posts
Re: JSON "Maxium length exceeded"
Mar 26, 2007 04:13 PM|LINK
Aleksey,
Thanx for your reply... that works! It seems that the web.config setting overrides whatever setting you manually try to set maxlength to later. Doh!
Thanx again,
J'son
J'son
maira.wenzel
Member
511 Points
111 Posts
Microsoft
Re: JSON "Maxium length exceeded"
Mar 29, 2007 09:01 PM|LINK
I know you already got it working, but just to explain how it works...
If you're using the JavaScriptSerializer class programmatically, you can set the MaxJsonLength property. But the only way to set the maximum length for invoking web methods from client script is through the web.config file.
See:
http://ajax.asp.net/docs/mref/P_System_Web_Script_Serialization_JavaScriptSerializer_MaxJsonLength.aspx
http://ajax.asp.net/docs/mref/P_System_Web_Configuration_ScriptingJsonSerializationSection_MaxJsonLength.aspx
Regards,
Maíra
jerkham
Member
3 Points
1 Post
Re: JSON "Maxium length exceeded"
Apr 09, 2008 03:27 PM|LINK
And that section in the web. config looks like this...
<system.web.extensions> <scripting> <webServices> <!-- Uncomment this line to customize maxJsonLength and add a custom converter --> <jsonSerialization maxJsonLength="500000"> <!--<converters> <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/> </converters>--> </jsonSerialization> <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. --> <!-- <authenticationService enabled="true" requireSSL = "true|false"/> --> <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. --> <!-- <profileService enabled="true" readAccessProperties="propertyname1,propertyname2" writeAccessProperties="propertyname1,propertyname2" /> --> </webServices> <!-- <scriptResourceHandler enableCompression="true" enableCaching="true" /> --> </scripting> </system.web.extensions>