While working on a project yesterday I ran into a typical WCF error scenario. The requests that were being sent to the service were larger than the defaults allow. This results in a 413 error with the text ‘Request Entity Too Large’ The default of 64kb is there to prevent DoS attacks. If you want to increase the allowed request size you need to modify the binding configuration. You can find many topics on this on the internet. Below you can find a sample:
<system.serviceModel> <bindings> <basicHttpBinding> <binding maxReceivedMessageSize="5242880"> <readerQuotas ... /> </binding> </basicHttpBinding> </bindings> </system.serviceModel>
Unfortunately this did not solve the problem for me, I spent quite some time to resolve the issue. Turns out I also had to modify the IIS settings of the website that was hosting the WCF service. The config setting is called ‘uploadReadAheadSize’ and can be found in the serverRuntime section below system.webServer and you can use the configuration editor feature of IIS manager to modify it. Give it the same or a larger value you specify in your WCF configuration.
3 Replies to “WCF HTTPS And Request Entity Too Large”
Extra background information: The ‘uploadReadAheadSize’ modification is needed because the entire request entity body is preloaded during SSL negotiation. For HTTP requests, the WCF config setting should be enough to get things working.
There is some evidence that using uploadReadAheadSize to fix this issue causes CPU spikes. Try this instead:
Thanks for the info!