将MaxReceivedMessageSize属性放在WCF服务的web.config文件中的位置?

mar*_*rko 12 c# wcf

我需要更改我的web.config文件并添加MaxReceivedMessageSize属性web.config- 但在哪里?

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

   <?xml version="1.0"?>
   <configuration>
      <system.web>
        <compilation debug="false"><assemblies><add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /></assemblies></compilation>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
Run Code Online (Sandbox Code Playgroud)

mar*_*c_s 33

您需要为要使用的绑定定义绑定配置,然后需要定义服务(在服务器端)和客户端(在客户端)以使用该绑定和绑定配置:

<system.serviceModel>
   <bindings>
      <!-- pick whichever binding you want .... -->
      <basicHttpBinding>
         <!-- binding configuration with a name -->
         <binding name="ExtendedMaxSize"  
             maxBufferSize="999999" maxReceivedMessageSize="999999" />
      </basicHttpBinding>
  </bindings>
  <services>
    <service name="Yournamespace.YourServiceClass" behaviorConfiguration="...">
      <!-- define endpoint with your binding and the name of the binding configuration
           that you have defined just above -->
      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="ExtendedMaxSize"  
                contract="Yournamespace.IYourServiceContract" />
    </service>
  </services>
Run Code Online (Sandbox Code Playgroud)