# .NET and More > WPF, WCF, WF >  [RESOLVED] The remote server returned an error: (413) Request Entity Too Large.

## FunkyDexter

Hi Guys

I've implemented a small set of REST services using WCF.  One of the services recieves a large amount of data.  When calling it (this is when runnig it from visual studio - I haven't deployed itto a production server yet) I get the error:-
The remote server returned an error: (413) Request Entity Too Large.

I've been doing some reading on t'internet and I gather this is because the default server that runs is set to reject large request to help prevent DOS attacks.  That makes sense but I need to increase the size to cope with my request.  This will ultimately go an an intranet so DOS attacks aren't a major concern.  Anyway, from what I've read on the net I've ended up adding the following to my Web.Config:-


```
<bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647" 
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="32"
                        maxArrayLength="2147483647"
                        maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
```

...but that hasn't worked.  Is there anything wrong with that or is there something else I should be doing?  Any advice?




Here's the full web config in case the problem is elsewhere:-


```
<?xml version="1.0"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\Temp\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647" 
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="32"
                        maxArrayLength="2147483647"
                        maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">          
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>  
</configuration>
```



edit> It's worth mentioning that I'm way out of my comfort zone here.  The chances of me having done something completely bone-headed are high.

----------


## HongKongCV

You also need settings on the client side. Look at the following two values and make sure they're set large in the app.config for the client app.



```
maxBufferSize="2147483647" 
maxReceivedMessageSize="2147483647"
```

This is what it looks like for my client app:



```
<bindings>
    <basicHttpBinding>
        <binding name="BasicHttpBinding_IPolicyMaintenanceService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" receiveTimeout="00:30:00" sendTimeout="00:30:00" />
    </basicHttpBinding>
</bindings>
```

And yeah, setting up these web services is as much art as it is science... imho.

----------


## FunkyDexter

The client app is a class library so doesn't have a web.config.  Is there an equivalent?

----------


## techgnome

You should still be able to use a config file... If I remember right library configs will get merged into the app.config during building. 


Or maybe not. You can hace settings in a class, I jsut tried.. no issue with it... what I couldn't figure out what where it all goes.


-tg

----------


## KGComputers

> I've implemented a small set of REST services using WCF


If it's a REST service, use webHttpBinding.


```
<bindings>
   <webHttpBinding>
    <binding 
      maxBufferPoolSize="2147483647" 
      maxReceivedMessageSize="2147483647" 
      maxBufferSize="2147483647" transferMode="Streamed">
    </binding>  
   </webHttpBinding>
</bindings>
```

413-request-entity-too-large-uploadreadaheadsize

----------


## FunkyDexter

Thanks KGC, that did it perfectly

And thanks to everyone for the suggestions.

----------


## KGComputers

NP..   :Smilie:   :Thumb:

----------

