javascript – JSON参数大小限制

我使用jQuery $.ajax json POST调用我的WCF Web服务.
其中一个输入参数非常长 – 超过8000字节.其中的数据是逗号分隔的GUID列表,如“78dace54-1eea-4b31-8a43-dcd01e172d14,ce485e64-e7c6-481c-a424-2624371180aa,ede4c606-f743-4e0a-a8cc-59bcffa7feda,f0a81ed1-80db- 4f6d-92d7-2fc47759a409\” .
当该参数为8176字节长时,请求成功.当它是8213(一个逗号和GUID) – 请求失败.
它从浏览器和fiddler(HTTP调试代理)失败.
我把它添加到webservice config中:
<configuration>
<system.web.extensions>
    <scripting>
        <webServices>
            <jsonSerialization maxJsonLength="50000000" recursionLimit="50000"/>
        </webServices>
    </scripting>
</system.web.extensions>

这没有任何区别,请求仍然失败,输入参数超过8176字节长.
该输入参数映射到WCF端的String.
我失踪了什么谢谢!

更新,这解决了我的问题:
原来这个设置控制了JSON消息的总长度

<webServices>
     <jsonSerialization maxJsonLength="50000000" recursionLimit="50000"/>
</webServices>

还有另一个设置可以控制各个参数的最大长度:

<bindings>
  <webHttpBinding>
    <binding name="Binding_Name" maxReceivedMessageSize="900000">
      <readerQuotas maxDepth="32" maxStringContentLength="900000" maxBytesPerRead="900000" maxArrayLength="120000" maxNaMetableCharCount="120000"/>
    </binding>
  </webHttpBinding>
</bindings>

另外,请确保设置:

<system.web>
     <httpRuntime maxRequestLength="900000"/>

希望这里有一些头疼!

解决方法

实际限制似乎是8192字节.

你必须在system.serviceModel标签中检查你的Web.config

<system.serviceModel>
  <bindings>
   <basicHttpBinding>
     <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassproxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNaMetableCharCount="16384"/>
     <security mode="None">
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
      <message clientCredentialType="UserName" algorithmSuite="Default"/>
     </security>
    </binding>
   </basicHttpBinding>
  </bindings>

您需要将maxStringContentLength =“8192”更改为更大的值.

您也可以使用多个请求而不是一个请求来逐页获取GUID列表,每个请求中都使用偏移量参数.例如,要获取200个页面的GUID列表,首先请求偏移= 0,第二个以offset = 200,…直到您获得少于200个项目.

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...