首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >413请求实体太大

413请求实体太大
EN

Stack Overflow用户
提问于 2016-05-12 13:30:15
回答 1查看 678关注 0票数 0

我已经看过关于这个主题的其他文章,并且认为我已经尝试了所有的东西,并且在试图保存一个更大的文件时似乎无法解决这个错误。我已经在配置文件的两个部分中增加了maxReceivedMessageSize和所有其他与大小相关的内容,并且还通过IIS增加了uploadReadAheadSize。我不知道我可能错过了什么,所以我会张贴我的配置文件,希望有人能够发现一些错误。

服务配置:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
      <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c5rge93gerg9" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" maxRequestLength="2147483647" />
  </system.web>
  <system.serviceModel>
      <client>
         <endpoint address="/" binding="basicHttpBinding" bindingConfiguration="MyHttpBinding" contract="*" name="Default" />
      </client>
    <bindings>
        <basicHttpBinding>
            <binding name="MyHttpBinding" hostNameComparisonMode="Exact" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483647" />
        </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
  </system.webServer>
  <connectionStrings>
  </connectionStrings>
  <entityFramework>
      <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>

客户端配置的相关部分:

代码语言:javascript
复制
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="MyHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
        </basicHttpBinding>
    </bindings>
<client>
  <endpoint address="http://Service1.svc" binding="basicHttpBinding"
    bindingConfiguration="MyHttpBinding" contract="ServiceReference1.IService1"
    name="MyHttpBinding" />
</client>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-12 17:39:22

我在您的服务配置中没有看到一个<services>部分,所以即使您用更大的值定义了一个绑定,也没有使用它,因为它没有被设置为默认的绑定,也没有显式地分配给一个端点。相反,您将得到一个具有默认配额和限制的basicHttpBinding

在您的情况下,最简单的修复方法可能是修复服务的配置文件,删除<client>部分并添加一个<services>部分,如下所示:

代码语言:javascript
复制
<services>
  <service name="MyServiceName">
    <endpoint address="/" 
              binding="basicHttpBinding"
              bindingConfiguration="MyHttpBinding" 
              contract="*" 
              name="Default" />
  </service>
</services>

这将将"MyHttpBinding“配置分配给您的端点。

注意,还可以通过省略MyHttpBinding属性使“basicHttpBinding”成为所有basicHttpBinding端点的默认配置。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37188451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档