Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put MaxReceivedMessageSize property in WCF service's web.config file?

Tags:

c#

wcf

I need to change my web.config file and add the MaxReceivedMessageSize property in my web.config - but where?

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

   <?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>
like image 463
marko Avatar asked Apr 01 '12 18:04

marko


1 Answers

You need to define a binding configuration for the binding you want to use and then you need to define your services (on the server-side) and clients (on the client side) to use that binding and binding configuration:

<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>
like image 69
marc_s Avatar answered Sep 28 '22 00:09

marc_s