简体   繁体   English

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

[英]Web Service error : HTTP 413: Request Entity Too Large

My system:我的系统:

IIS 7.5 IIS 7.5

Visual Studio 2010视觉工作室 2010

Framework 4框架 4

I have make a Web Service that receive a file(byte array).我制作了一个接收文件(字节数组)的 Web 服务。 I have make a console app that consume it(Add Service Reference-->Advance-->Add Web Reference).我制作了一个使用它的控制台应用程序(添加服务参考--> 高级--> 添加 Web 参考)。 With http it is working perfectly.使用http它可以完美运行。 But I need to consume it with https.但我需要用 https 来消费它。 So, when I try to consume it with https, it is giving me HTTP 413: Request Entity Too Large.因此,当我尝试使用 https 使用它时,它给了我 HTTP 413:请求实体太大。 I have been reading a lot, but it is impossible.我已经阅读了很多,但这是不可能的。 I have tried to put in the webconfig of the Web Service:我试图放入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>

The file is not too large.文件不是太大。 Where do I need to put the max size?我需要把最大尺寸放在哪里?

Thank感谢

Many times by adding line多次通过添加行

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

gives 500 error给出 500 错误

Please find out Which is allready exists in your web configuration file Hi guys Generally 500 error occurs if there any wrong configuration in the web.config fix that first.请找出您的 web 配置文件中已经存在的内容 大家好,如果 web.config 中的任何错误配置首先修复,通常会出现 500 错误。 Here I am providing 413 entity is too large on https protocol issue fix在这里,我在 https 协议问题修复中提供了 413 实体太大

web.config before issue fixed问题修复前的 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>

we just copy pasted readerquotas maxBufferPoolSize maxReceivedMessageSize in the Transport mode RestServiceBindingConfig this made the trick first RestServiceBindingConfig is for https second HttpRestServiceBindingConfig binding for http我们只是在传输模式 RestServiceBindingConfig 中复制粘贴的 readerquotas maxBufferPoolSize maxReceivedMessageSize 这使得技巧首先 RestServiceBindingConfig 用于 https 第二个 HttpRestServiceBindingConfig 绑定用于 http

web.config after issue fixed问题修复后的 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM