WCF service doesn’t accept files over 64 KB

This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.

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.

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.