Tech Tips
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How to configure maxJsonLength in ASP.NET AJAX applications

Go down

How to configure maxJsonLength in ASP.NET AJAX applications Empty How to configure maxJsonLength in ASP.NET AJAX applications

Post  Admin Sat Dec 31, 2011 9:48 am

The maximum length of JSON strings, by default is 2097152 characters, which is equivalent to 4 MB of Unicode string data. This should be good enough for most of the web applications. If the size of serialized data you want to send to the client is larger than this default value, you may change it either programmatically or declaratively (in the web.config file of the web site). However, I personally wouldn't go over the 4MB threshold because serializing a large chunk of data across the wire normally causes huge performance penalty. From my experience, you may want to take a serious look at your application design if you need JSON strings longer than 2097152 characters.
To set this value in your code, you can simply assign an integer to the JavaScriptSerializer.MaxJsonLength property. Alternatively, you can configure the max length in the system.web.extensions configuration section in web.config. The example below sets the maxJswonLength value to 500000 characters. Also bear in mind that the maxJsonLength in the web.config file automatically overrides the JavaScriptSerializer.MaxJsonLength property.

<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions><system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>


http://geekswithblogs.net/frankw/archive/2008/08/05/how-to-configure-maxjsonlength-in-asp.net-ajax-applications.aspx

Admin
Admin

Posts : 60
Join date : 2009-06-05

https://softro.forumotion.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum