gpt4 book ai didi

wcf - Json Web服务最大内容长度?

转载 作者:行者123 更新时间:2023-12-04 23:53:58 26 4
gpt4 key购买 nike

我一直在构建一个 json 格式的 Asp.net WCF Web 服务。现在我想真正测试它在发送大量数据时是如何工作的。我的 http 帖子的内容长度是 65595。直接尝试连接时,我收到错误“HTTP/1.1 400 Bad Request”。似乎它甚至没有尝试。

我知道我正在发送有效的 json,我发送的是一个包含大约 1000 个项目的数组,每个项目的 json 如下所示:
{"oid":0,"am":1,"me":2,"ofooid":0,"fooid":1104,"sync":1,"type":1,"id":1443,"日期":"2009-09-24"}

如果我只是删除数组中的一项,因此总内容长度为 65484,它就可以完美运行。所以它似乎是某个地方的魔法极限。是 Asp.net 限制了请求的大小,如果是这种情况,我该如何更改最大大小?

我的 Web.Config 文件看起来像,我想我应该在这里的某个地方设置最大值,但我只是不知道在哪里:

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="Service" />
</service>
</services>
</system.serviceModel>

最佳答案

您需要在 WebHttpBinding 的绑定(bind)配置中增加 maxReceivedMessageSize。默认值为 65536。参见 WebHttpBinding configuration documentation了解所有信息。

另请注意,您可能需要通过 httpRuntime 配置增加 ASP.NET maxRequestLength。默认值为 4 MB,但您可能需要增加:

<httpRuntime maxRequestLength="10000" />

关于wcf - Json Web服务最大内容长度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1525841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com