[SOLVED] The remote server returned exception: (413) Request Entity Too Large

Issue

I know that this question has been asked a ton of times, but I have unfortunately not been able to adapt the answers into a working solution.

I have a WCF service, running in the IIS, that throws a 413 exception when I try to send requests that exceed 64KB in size. From all the research I have done it should be enough to set the maxReceivedMessageSize.
The problematic service is the Validation service. I am trying to send an object with attachments that have been base64 encoded into a byte[].

I am running this in a VM running Windows Server 2019 Standard, but this problem is also present in other environments.

I have posted pastebin links to the stacktrace, Web.config, and the App.config to not explode size of the post.

Stacktrace
https://pastebin.com/zbSF0nfB

Web.config snippet

<binding name="BasicHttpBinding_IValidationService" maxBufferPoolSize="2147483647"
      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="Ntlm" />
      </security>
    </binding>

https://pastebin.com/V5TRBFsQ

App.config
https://pastebin.com/Hr7NcBTJ

I hope that someone is able to find a mistake that I have made 🙂

Solution

The solution was found in this post (How to override WebServiceHostFactory MaxReceivedMessageSize?)

The problem was the factory creating the host for the service, because it was a default SharePoint factory/host it did not respond to the changes made in the different web.config files. The solution was therefore to replace the factories with custom factories that created the hosts with the parameters that would normally be specified in the web.config files.

Answered By – Frederik Andersen

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.