Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

C# - The Length of the String Exceeds the Value Set on the Maxjsonlength Property in Asp.net

Aug 26, 2015
Introduction

Here I will explain how to solve the problem of “Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.” in
asp.net using c#, vb.net.

Description:
  
In previous articles I explained gridview examples in asp.net, dropdownlist examples in asp.net,
jQuery regular expression to validate url without http(s), regular expression to validate phone number in jquery, regular expression to replace all special characters with spaces in c#, regex email validation in c# and many articles relating to jQuery, asp.net. Now I will explain how to solve the problem of length of the string exceeds the value set on the maxJsonLength property.” in asp.net.

Generally this problem occur whenever our json result set length exceeds default json MaxJsonLength property value. By default MaxJsonLength property will allow 102400 (100k) in case our string exceeding this length we will get JavaScriptSerializer error.

To solve this problem we need to set MaxJsonLength property value in web.config file like as shown below


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

Once we add above code snippet in web.config file automatically our problem will get solve I hope it helps you…… Happy coding…… 

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

I put this code snippet into my web.config, still I am getting the same exception

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.