Blog Post

IIS Support Blog
1 MIN READ

413 Request Entity Too Large when connecting to a WCF service

JasonXu's avatar
JasonXu
Icon for Microsoft rankMicrosoft
Feb 08, 2019

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>

Published Feb 08, 2019
Version 1.0

2 Comments

  • chilberto's avatar
    chilberto
    Iron Contributor

    Thanks JasonXu 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?