title: The remote server returned an unexpected response: (413) Request Entity Too Large.
body: <p>I'm trying to build a WCF Application service, using FW4.0.
  My service work correctly when transferring EntiryFramework object between Server and client. But I'm having problem passing EF object from Client to Server.</p>
  
  <p>Here some more detail about my environment:
  - The service is running in debug mode locally on IIS
  - I'm running all this on my Windows 7
  - I'm using Visual Studio 2010 on FW4.0</p>
  
  <p>I'm trying to send a object (tblClient) to server to save the record, but a keep having the error (413) Request Entity Too Large.
  Here the full stack:</p>
  
  <pre><code>System.ServiceModel.ProtocolException occurred
        HResult=-2146233087
        Message=The remote server returned an unexpected response: (413) Request Entity Too Large.
        Source=mscorlib
        StackTrace:
          Server stack trace:
             at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
             at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
             at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
             at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
             at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
             at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
             at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
          Exception rethrown at [0]:
             at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
             at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
             at ClientApp.ServiceReference1.IService.SaveClient(tblClient client)
             at ClientApp.ServiceReference1.ServiceClient.SaveClient(tblClient client) in C:\dufh\WPF Project\ClientApp\Service References\ServiceReference1\Reference.vb:line 2383
             at ClientApp.ViewModel.ClientViewModel.SaveClient() in C:\dufh\WPF Project\ClientApp\ViewModel\ClientViewModel.vb:line 48
        InnerException: System.Net.WebException
             HResult=-2146233079
             Message=The remote server returned an error: (413) Request Entity Too Large.
             Source=System
             StackTrace:
                  at System.Net.HttpWebRequest.GetResponse()
                  at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
             InnerException:
  </code></pre>
  
  <p>I've do some research and all point to the maxBufferSize and/or maxBufferPoolSize and/or maxReceivedMessageSize witch is not large enough in the Client config App.Config. So I inscresed them to maximum value :
  maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  But still the error remain.</p>
  
  <p>Here my full Client App.Config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;system.diagnostics&gt;
      &lt;sources&gt;
        &lt;!-- This section defines the logging configuration for My.Application.Log --&gt;
        &lt;source name="DefaultSource" switchName="DefaultSwitch"&gt;
          &lt;listeners&gt;
            &lt;add name="FileLog"/&gt;
            &lt;!-- Uncomment the below section to write to the Application Event Log --&gt;
            &lt;!--&lt;add name="EventLog"/&gt;--&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt;
      &lt;switches&gt;
        &lt;add name="DefaultSwitch" value="Information" /&gt;
      &lt;/switches&gt;
      &lt;sharedListeners&gt;
        &lt;add name="FileLog"
             type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
             initializeData="FileLogWriter"/&gt;
        &lt;!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --&gt;
        &lt;add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="MVVM Sampling"/&gt;
      &lt;/sharedListeners&gt;
    &lt;/system.diagnostics&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="BasicHttpBinding_IService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://localhost:7803/Service1.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService"
            name="BasicHttpBinding_IService" /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and the full Web.Config WCF service Web.Config</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
  
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="BasicHttpBinding_IService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"&gt;
            &lt;readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" /&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
  
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
  
  
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
    &lt;connectionStrings&gt;
      &lt;add name="MaitreEntities" connectionString="metadata=res://*/Schemat.csdl|res://*/Schemat.ssdl|res://*/Schemat.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=INFOFILE2\SQL2008R2;initial catalog=0001ConneryFerland;user id=sa;password=kermit80;multipleactiveresultsets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  
  
  Any help would be very welcome :-)
  </code></pre>