title: The remote server returned an unexpected response: (413) Request Entity Too Large.?
body: <p>I pass some values to my WCF service from the .net application in string format. Passing string format will be in this structure, </p>
  
  <pre><code>ItemName~ItemDescription~ItemPrice|ItemName~ItemDescription~ItemPrice|...
  </code></pre>
  
  <p>Every line item will be separated by '|' character. I was passing nearly 1000 items. It was working as expected, but when I came to pass 1500 items, this error occurs.</p>
  
  <p><code>The remote server returned an unexpected response: (413) Request Entity Too Large.</code></p>
  
  <p>Please help me in fixing this error. </p>
  
  <p>This is the method in service</p>
  
  <pre><code>private void InsertGpLineItems(string lineItems)
  {
      //Here I will process the insertion of line items to the GP system.
  }
  </code></pre>
  
  <p>This is <strong>web.config</strong> at my WCF service.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="connectionString" value="data source=localhost; initial catalog=TWO; integrated security=SSPI"/&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
      &lt;pages validateRequest="false" /&gt;
      &lt;httpRuntime requestValidationMode="2.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.diagnostics&gt;    
      &lt;sources&gt;
        &lt;source name="System.ServiceModel.MessageLogging"
                switchValue="Information, ActivityTracing, Error"&gt;
          &lt;listeners&gt;
            &lt;add name="messages"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="messages.svclog" /&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt; 
    &lt;/system.diagnostics&gt;
    &lt;system.serviceModel&gt;
      &lt;diagnostics&gt;
        &lt;messageLogging logEntireMessage="true"
                        logMalformedMessages="true"
                        logMessagesAtServiceLevel="true"
                        logMessagesAtTransportLevel="true"
                        maxMessagesToLog="3000"
                        maxSizeOfMessageToLog="2000"/&gt;
      &lt;/diagnostics&gt;
      &lt;services&gt;
        &lt;service name="Service1.IService1"&gt;
          &lt;endpoint address="" binding="basicHttpBinding"
                    contract="Service1.IService1"&gt;
          &lt;/endpoint&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:50935/Service1.svc"/&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
          &lt;!--&lt;endpoint address="http://localhost:50935/Service1.svc" binding="basicHttpBinding"&gt;&lt;/endpoint&gt;--&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="SampleBinding" 
                   messageEncoding="Text"
                   closeTimeout="00:02:00"
                   openTimeout="00:02:00"
                   receiveTimeout="00:20:00"
                   sendTimeout="00:02:00"
                   allowCookies="false"
                   bypassProxyOnLocal="false"
                   hostNameComparisonMode="StrongWildcard"
                   maxBufferPoolSize="2147483647" 
                   maxBufferSize="2147483647"
                   maxReceivedMessageSize="2147483647"
                   textEncoding="utf-8"
                   transferMode="Buffered"
                   useDefaultWebProxy="true"&gt;          
            &lt;readerQuotas maxDepth="2000000"
                          maxStringContentLength="2147483647"
                          maxArrayLength="2147483647"
                          maxBytesPerRead="2147483647"
                          maxNameTableCharCount="2147483647"  /&gt;
            &lt;security mode="Transport"&gt;
              &lt;transport clientCredentialType="None" 
                         proxyCredentialType="None" 
                         realm=""&gt;
              &lt;/transport&gt;
            &lt;/security&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;endpointBehaviors&gt;
          &lt;behavior name="behaviorGPLineItemsService"&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&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;/configuration&gt;
  </code></pre>