JSON限制为1180个字符 [英] JSON Limited to 1180 Characters
问题描述
我有一个简单的JavaScript JSON请求,该请求对要通过JSON请求发送到我的C#Web服务器的对象进行字符串化处理.
I have a simple JavaScript JSON request which stringify's an object to send via a JSON request to my C# Web server.
每当stringy返回的字符串超过1180个字符时,服务器上都不会调用WebMethod.
Whenever the string returned by stringy is over 1180 characters, the WebMethod is not called on the server.
据我了解,客户端可以通过JSON发送多少字符串数据没有限制.我知道限制是在服务器端,试图接受参数化的请求.
From my understanding, there is no limit on how much string data the client can send via JSON. I understand that the limitation is on the server end, trying to accept the paramaterized request.
web.config中是否可以增加1180的限制?
Is there somewhere in the web.config that I can increase this limit of 1180?
我当前的配置;
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;initial catalog=aspnetdb" providerName="System.Data.SqlClient"/>
<add name="ApplicationServices2" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;initial catalog=trimweb" providerName="System.Data.SqlClient"/>
<add name="ApplicationServices3" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;initial catalog=Customers" providerName="System.Data.SqlClient"/>
<add name="ApplicationServices4" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;initial catalog=OrderUpdate;User ID=test1;Password=test1;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<services>
<service name="ServiceSite.CustomersService">
<endpoint address="" binding="webHttpBinding"
bindingConfiguration="webHttpBindingWithJsonP" contract="ServiceSite.CustomersService"
behaviorConfiguration="webHttpBehavior"/>
</service>
</services>
</system.serviceModel>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
推荐答案
您需要将webHttpBinding
更改为以下内容:
Youll need to change your webHttpBinding
to something like the below:
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"/>
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
</webHttpBinding>
注意:在ASP.NET兼容模式下,仅增加此值是不够的.您还应该增加httpRuntime的值(请参见 httpRuntime ).
Note: Increasing this value alone is not sufficient in ASP.NET compatible mode. You should also increase the value of httpRuntime (see httpRuntime).
这应该类似于:
<httpRuntime
maxQueryStringLength = "2048"
maxRequestLength="4096"
maxUrlLength = "260"
requestLengthDiskThreshold="80"/>
(根据需要增加金额)
这篇关于JSON限制为1180个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!