This article is contributed. See the original author and article here.

While trying to upload files that are bigger than 64 KB, we came across this error: 413 Request Entity Too Large.


 

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

 


 


 


The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.


 


As the error above mentions, this issue occurs because the request size is bigger than the MaxReceivedMessageSize for WCF.


 


Solution


Increase MaxReceivedMessageSize value for your web service to solve this issue. However, this may get tricky because there are two different MaxReceivedMessageSize parameters:



  • MaxReceivedMessageSize in System.ServiceModel.Configuration.BasicHttpBindingElement

  • MaxReceivedMessageSize in System.ServiceModel.Channels.HttpTransportBindingElement


 


This configuration below will increase the MaxReceivedMessageSize in System.ServiceModel.Configuration.BasicHttpBindingElement


 

<basicHttpBinding>
   <binding name="basicHttpBinding_Portal" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
       <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647"/>
    </binding>
</basicHttpBinding>

 


 


 


You should increase the MaxReceivedMessageSize in System.ServiceModel.Channels.HttpTransportBindingElement as well:


 

<customBinding>
   <binding closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00">
      <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" useDefaultWebProxy="true" transferMode="Buffered" />
   </binding>
</customBinding>

 


 


You can also do it in the code as explained in this document.

Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.

%d bloggers like this: