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

Frederik Andersen 1 Reputation point
2022-07-04T14:37:22.853+00:00

Hello

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 as I had trouble with the code formatted.

Stacktrace
https://pastebin.com/zbSF0nfB

Web.config
https://pastebin.com/V5TRBFsQ

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

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

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,385 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 25,556 Reputation points Microsoft Vendor
    2022-07-05T02:30:30.627+00:00

    Hi @Frederik Andersen ,
    You can increase multiple locations to the maximum possible size. Some of them are related to WCF, some of them are related to IIS. Please try adding the following (maxRequestLength and maxAllowedContentLength) to the config file on the ser ver side to take care of the IIS side:

    <system.web>  
      <httpRuntime maxRequestLength="2147483647" useFullyQualifiedRedirectUrl="true"   executionTimeout="14400"/>  
    </system.web>  
    <system.webServer>  
       <modules runAllManagedModulesForAllRequests="true"/>  
        <security>  
         <requestFiltering allowDoubleEscaping="true">  
          <requestLimits maxAllowedContentLength="2147483647"/>  
          <fileExtensions allowUnlisted="true"/>  
          <verbs allowUnlisted="true"/>  
         </requestFiltering>  
        </security>  
      </system.webServer>  
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.