Request Entity Too Large - IIS 10 error on request sent

MWBQ 0 Reputation points
2023-03-21T09:51:09.8133333+00:00

Hi.

I receive the "Request Entity Too Large" on sending a request to an application set up in IIS. The size of the message is ~150 kb, which is a little bit higher than the default limit. I have tried a few potential solutions:

  • set uploadReadAheadSize to max value (2147483647)
  • set custom webHttpBinding
   <webHttpBinding>
   
           <binding
   
             name="webHttpBindingIncreasedSize"
   
             receiveTimeout="01:00:00"
   
             maxBufferPoolSize="2147483647"
   
             maxReceivedMessageSize="2147483647"
   
             maxBufferSize="2147483647"
   
             transferMode="Streamed"
   
             >
   
             <readerQuotas
   
                 maxDepth="2147483647"
   
                 maxStringContentLength="2147483647"
   
                 maxArrayLength="2147483647"
   
                 maxBytesPerRead="2147483647"
   
                 maxNameTableCharCount="2147483647"/>
   
             <!-- binding config: security, httpTransport and more  -->
   
           </binding>
   
         </webHttpBinding>
  • using said custom webBinding
<services>

      <service name="Namespace.Importer" behaviorConfiguration="ImporterBehavior">

        <endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpBindingIncreasedSize" contract="Namespace.IImporter"

                       behaviorConfiguration="web" />

      </service>

    </services>
  • change endpointBehaviour by adding maxItemsInObjectGraph
<endpointBehaviors>

        <behavior name="web">

          <dataContractSerializer maxItemsInObjectGraph="2147483647" />

          <webHttp/> 

        </behavior>

      </endpointBehaviors>
  • add maxRequestLength to httpRuntime
   <httpRuntime targetFramework="4.5" maxRequestLength="1048576" />
      • use customBinding
<customBinding>
        <binding>
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" useDefaultWebProxy="true" transferMode="Buffered" />
        </binding>
      </customBinding>
  • set maxAllowedContentLength to 1073741824
   <security>
         <requestFiltering>
           <!-- Measured in Bytes -->
           <requestLimits maxAllowedContentLength="1073741824" />
           <!-- 1 GB-->
         </requestFiltering>
       </security>

Unfortunately nothing solved the issue and i am still stuck with the same error: Request Entity Too Large . Any help would be appreciated.

Internet Information Services
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. TengFeiXie-MSFT 346 Reputation points
    2023-03-22T06:53:30.36+00:00

    Hi @MWBQ

    The solution you tried was this document? Alright, changing uploadReadAheadSize does not work in all cases.

    You can try the following steps:

    1. Go to IIS.
    2. Click on the server name
    3. In the features (icons), chose the configuration editor.
    4. Click on the dropdowns on the top with Settings
    5. Traverse the path system.webServer -> security -> requestFiltering -> maxAllowedContentLength and set it to 334217728. (Then hit enter and then apply on the top right).

    Also you can try below settings:

    <system.web>
      <httpRuntime maxRequestLength="1048576" />
    </system.web>
    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="1073741824" /> 
        </requestFiltering>
      </security>
    </system.webServer>
    

    Refer to: https://stackoverflow.com/a/73481150/20058276

    Best Regard,

    TengFei Xie


    If the answer is the right solution, please click "Accept Answer" and kindly upvote. 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.


  2. Lex Li (Microsoft) 5,577 Reputation points Microsoft Employee
    2023-03-28T23:20:03.5166667+00:00

    While you changed most IIS and WCF related settings, have you tried HTTP API settings?

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters\MaxFieldLength   
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters\MaxRequestBytes
    

    https://learn.microsoft.com/en-US/troubleshoot/developer/webapps/iis/iisadmin-service-inetinfo/httpsys-registry-windows#registry-keys

    https://knowledge.broadcom.com/external/article/172865/the-request-failed-with-http-status-413.html


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.