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

发布时间 2023-11-07 10:59:50作者: 蒙蒙浮霁月

一个报表的查询,用ajax调用的Service,查询条件没有问题,后台也能返回数据,就一直返回Error提示,F12看到是因为返回json时出错了

 

在web.config的configuration加以下代码即可解决

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