WCF REST POST 操作抛出 413(实体太大)错误

发布于 2024-12-26 18:23:34 字数 246 浏览 1 评论 0原文

我使用内置项目模板创建了一个基于 WCF REST 的服务。一切都工作得很好,除了当我尝试将文件(作为流)“发布”到我的其中一个操作时,我始终收到 413(实体太大)响应。

我查看了与 WCF 相关的所有其他 413 个问题,它们都与非 RE​​ST 服务和/或 IIS6 配置相关,并提到了 <绑定>属性。

有什么想法吗?

I've created, using the built-in project template, a WCF REST-based service. Everything works just great except that when I attempt to "POST" a file (as a stream) to one of my operations, I'm consistently getting a 413 (Entity Too Large) response.

I've looked at all the other 413 questions related to WCF and they're all related to non-REST services and/or IIS6 configurations and mention either the <system.Web> or <binding>properties.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦醒时光 2025-01-02 18:23:34

嗯……我想通了!

事实证明,有效的设置必须应用于 system.serviceModel 节点内的 standardEndpoint 节点:

<system.serviceModel>
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint name=""
                 helpEnabled="true"
                 automaticFormatSelectionEnabled="true"
                 maxReceivedMessageSize="2147000000"
                 />
        </webHttpEndpoint>
    </standardEndpoints>
</system.serviceModel>

Well... I figured it out!

It turns out that the setting which worked is one which has to be applied to the standardEndpoint node inside system.serviceModel node:

<system.serviceModel>
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint name=""
                 helpEnabled="true"
                 automaticFormatSelectionEnabled="true"
                 maxReceivedMessageSize="2147000000"
                 />
        </webHttpEndpoint>
    </standardEndpoints>
</system.serviceModel>
£噩梦荏苒 2025-01-02 18:23:34

检查配置文件 maxmessagesize 等中的配额和最大值。默认值为 8192、16384、65536

Check the quotas and max's in your config file maxmessagesize, etc. defaults are 8192, 16384, 65536

时光沙漏 2025-01-02 18:23:34

我似乎遇到了同样的问题,最终不得不为我的 RESTful 服务创建自定义绑定并增加 maxReceivedMessageSize 设置。

  <webHttpBinding>
    <binding name="RESTfulServiceBinding" maxReceivedMessageSize="50000000" />
  </webHttpBinding>

I had seemingly the same issue and ended up having to create a custom binding for my RESTful service and increase the maxReceivedMessageSize setting.

  <webHttpBinding>
    <binding name="RESTfulServiceBinding" maxReceivedMessageSize="50000000" />
  </webHttpBinding>
橙味迷妹 2025-01-02 18:23:34

我会检查 IIS 中设置的最大上传大小。过去,当我尝试发布文件时,这一直是问题。对于任何实际需要处理文件上传的应用程序来说,它通常设置得太小。

I would check the max upload size set in IIS. In the past, that has been the issue when I have tried to post files. It is usually set too small for any application that actually needs to deal with file uploads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文