如何增加MaxStringContentLength?

时间:2011-10-07 15:49:39

标签: wcf

当我下载大于1Mb的xml文件时,我有一个错误:

已超出传入邮件的最大邮件大小限额(8192)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。

我试图增加web.config文件中的MaxReceivedMessageSize值,但它不起作用。有人知道解决方案吗?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
<customErrors mode="Off"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" >
</compilation>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service
        behaviorConfiguration="ServiceGatewayBehavior"
        name="Marketing.WebService.Administration">
        <endpoint
          address=""
          binding="wsHttpBinding"
          bindingConfiguration="CustomBinding"
          contract="Marketing.WebService.Interfaces.IAdministration" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="CustomBinding">
          <readerQuotas
              maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
              maxDepth="2147483647"
              maxNameTableCharCount="2147483647"
              maxStringContentLength="2147483647" />
          <security mode="None">
            <message establishSecurityContext="false" />
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceGatewayBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

0 个答案:

没有答案