【问题标题】:Web Service error : HTTP 413: Request Entity Too LargeWeb 服务错误:HTTP 413:请求实体太大
【发布时间】:2022-03-18 11:02:10
【问题描述】:

我的系统:

IIS 7.5

Visual Studio 2010

框架 4

我已经创建了一个接收文件(字节数组)的 Web 服务。 我制作了一个使用它的控制台应用程序(添加服务引用--> 高级--> 添加 Web 引用)。使用http它可以完美运行。但我需要用 https 来消费它。因此,当我尝试使用 https 使用它时,它给了我 HTTP 413:请求实体太大。我已经阅读了很多,但这是不可能的。我已尝试将 Web Service 的 webconfig 放入:

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_INopService" maxReceivedMessageSize="22147483647" maxBufferPoolSize="252428800" maxBufferSize="22147483647">
          <readerQuotas maxDepth="256" maxStringContentLength="22147483647" maxArrayLength="2222216384"
            maxBytesPerRead="2222220000" maxNameTableCharCount="2222216384" ></readerQuotas>
        </binding>
      </basicHttpBinding>

<basicHttpBinding>
        <binding name="HttpBigMessage"
             receiveTimeout="00:10:00"
             sendTimeout="00:10:00"
             maxReceivedMessageSize="2147483647" >
          <security mode="None" />
        </binding>
      </basicHttpBinding>

  </bindings>

    <client>
      <endpoint address="https://localhost/hmenu/GetData.asmx"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INopService"
        contract="PhotoSavingsService.INopService" name="BasicHttpBinding_INopService" />
    </client>


  </system.serviceModel>

文件不是太大。 我需要把最大尺寸放在哪里?

谢谢

【问题讨论】:

标签: c# web-services console-application http-status-code-413


【解决方案1】:

多次加行

<httpRuntime maxRequestLength="214748364" executionTimeout="9999" 
targetFramework="4.5"/>

给出 500 错误

请找出您的网络中已经存在哪些 配置文件 嗨,大家好 如果配置有错误,一般会出现 500 错误 web.config 先解决这个问题。 这里我提供 413 entity is too large on https 协议问题修复

问题修复前的 web.config

<bindings>
  <webHttpBinding>
    <binding name="RestServiceBindingConfig">
      <security mode="Transport"></security>
    </binding>
    <binding name="HttpRestServiceBindingConfig">
      <security mode="None"></security>
    </binding>
<binding maxBufferPoolSize="76000000" maxReceivedMessageSize="19000000">
      <readerQuotas maxDepth="32" maxStringContentLength="19000000" 
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>

我们只是复制粘贴的 readerquotas maxBufferPoolSize maxReceivedMessageSize 在传输模式 RestServiceBindingConfig 这首先取得了成功 RestServiceBindingConfig 用于 https 的第二个 HttpRestServiceBindingConfig http 绑定

问题修复后的 web.config

<bindings>
  <webHttpBinding>
    <binding name="RestServiceBindingConfig" maxBufferPoolSize="2147483647" 
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
           maxArrayLength="2147483647" maxBytesPerRead="4096" 
           maxNameTableCharCount="16384" />
      <security mode="Transport"></security>
    </binding>
    <binding name="HttpRestServiceBindingConfig" 
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
           maxArrayLength="2147483647" maxBytesPerRead="4096" 
           maxNameTableCharCount="16384" />
      <security mode="None"></security>
    </binding>

  </webHttpBinding>
</bindings>
<behaviors>

【讨论】:

  • 请编辑你的答案,你可以看到代码和你的解释混在一起,如果你把代码和解释分开就完美了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-18
  • 2012-09-23
  • 1970-01-01
  • 2020-05-04
  • 2016-02-01
  • 2011-06-27
相关资源
最近更新 更多