413 Request Entity Too Large when connecting to a WCF service
Published Feb 08 2019 03:37 PM 13.3K Views
Microsoft

Error "413 Request Entity Too Large" when connecting to a WCF service.

 

Increase maxReceivedMessageSize and readerQuotas to resolve the error. Below is an example:

 

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="10485760">
<readerQuotas maxDepth="32" maxBytesPerRead="200000000" maxArrayLength="200000000" maxStringContentLength="200000000" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>

2 Comments
Copper Contributor

Thanks, That helps me

Iron Contributor

Thanks @Jason Xu for the post - It is important to consider if it makes sense to increase these binding default values. From the documentation:

 

MaxReceivedMessageSize - the maximum size, in bytes, for a message that can be received on a channel configured with this binding

readerQuotas - this complex object sets constraints on the complexity of SOAP messages that can be processed

maxDepth - maximum nested node depth

maxStringContentLength -  the maximum string length

maxArrayLength - the maximum allowed array length

 

So, if the particular scenario should not receive messages that contain unusually large strings or large number of arrays, then it is valid to reject messages that contain these. For example, if I have a message that contains a list of addresses. If the system in question only can have 10 addresses then why should the service receive messages that contain hundreds or thousands of addresses?

Version history
Last update:
‎Feb 08 2019 03:37 PM
Updated by: