• 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.>

    文章出处:www.cnblogs.com/jizhong

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。否则保留追究法律责任的权利。

  • 相关阅读:
    python_day3
    python-day2
    python-day1
    【收集】安卓手机在市场占比的网址查找
    while循环
    switch多选择结构
    if选择结构
    顺序结构
    Scanner:求和 、求平均值
    Scanner:用户交互
  • 原文地址:https://www.cnblogs.com/jizhong/p/1919000.html
Copyright © 2020-2023  润新知