JSON: Handling Max Records in JSON Response in ASP.NET

While working with JSON in getting records beyond a limit I am getting the following exception:

  • InvalidOperationException / Invalid Object.
  • Error during serialization or deserialization using the JSON.

To set maximum limit of your JSON response just go to your web.config file and do the following settings:

  1. <configuration>  
  2.   <system.web.extensions>  
  3.     <scripting>  
  4.       <webServices>  
  5.         <jsonSerialization maxJsonLength="50000000"/>  
  6.       </webServices>  
  7.     </scripting>  
  8.   </system.web.extensions>     
  9. </configuration>  
configuration
Figure 1.