Json MaxJsonLength Error

"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer.
The length of the string exceeds the value set on the maxJsonLength property.","StackTrace":"  
在 System.Web.Script.Serialization.JavaScriptSerializer.
Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)\r\n 
在 System.Web.Script.Serialization.JavaScriptSerializer.Serialize(
Object obj, SerializationFormat serializationFormat)\r\n 
在 System.Web.Script.Services.RestHandler.InvokeMethod
(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n  
在 System.Web.Script.Services.RestHandler.
ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}"

[Reprinted]While working with ajax calls and dealing with json data you may encounter this exception "Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property" . The reason is that the data which you are dealing with for ajax call has crossed the default limit which is defined for jsonserialization.

From MSDN: http://msdn.microsoft.com/en-us/library/bb763183.aspx

"maxJsonLength. Specifies the maximum length of the JSON string (the maximum number of UTF-8 characters). The default length is 102400."

So the solution is that you need to increase the value for jsonserialization attribute. For example I set it to "500000"

view sourceprint

< system.web.extensions >   

  
< scripting >   

    
< webServices >   

      
< jsonSerialization maxJsonLength = " 500000 " />   

    
</ webServices >   

  
</ scripting >   

</ system.web.extensions >  

Below is the screen shot with the position where you need to place the "jsonserialization" tag.>

你可能感兴趣的:(length)