zoukankan      html  css  js  c++  java
  • ASP.NET MVC Json()处理大数据异常解决方法,字符串的长度超过了为 maxJsonLength

    问题:

    使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过了为 maxJsonLength 属性设置的值

    <system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="1024000000" />
            </webServices>
        </scripting>
    </system.web.extensions>
    这个方法测试了没有效果。

    stackoverflow上找到答案

    public ContentResult GetOrderList()
            {
                try
                {
                    IList<OrderAll> list = new List<OrderAll>();
    
    
    return new ContentResult { Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(UnifyResponse.ReturnFun(list)), ContentType = "application/json"
    
                    };
    
                    //return this.Json(UnifyResponse.ReturnFun(list));
                }
                catch (Exception ex)
                {
                    return new ContentResult
                    {
    
                        Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(UnifyResponse.ThrowError(ex)),
                        ContentType = "application/json"
                    };
                    //return this.Json(UnifyResponse.ThrowError(ex));
                }
            }
  • 相关阅读:
    Hive_MySQL安装
    Hive_安装部署
    Hive_和关系数据库比较
    Hive_架构原理
    Hive_优缺点
    Hive_什么是Hive
    java中的编码规范(1)
    SpringBoot_常用注解
    什么是WebMvcConfigurer
    什么是大数据倾斜
  • 原文地址:https://www.cnblogs.com/tangge/p/5632060.html
Copyright © 2011-2022 走看看