Web 服务错误:HTTP 413:请求实体太大

问题描述 投票:0回答:1

我的系统:

IIS 7.5

视觉工作室 2010

框架 4

我制作了一个接收文件(字节数组)的 Web 服务。 我制作了一个使用它的控制台应用程序(添加服务参考-->高级-->添加 Web 参考)。使用 http 它工作得很好。但我需要使用 https 来使用它。因此,当我尝试通过 https 使用它时,它会给我 HTTP 413:请求实体太大。我看了很多书,但这是不可能的。我试图放入 Web 服务的 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个回答
0
投票

通过添加行多次

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

给出 500 个错误

请找出您的网站中已经存在的 配置文件 嗨,大家好 一般配置有错误会出现500错误 web.config 首先解决这个问题。 在这里我提供 413 entity is too large on https protocol issue fix

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>
© www.soinside.com 2019 - 2024. All rights reserved.