How to Send Large Amounts of Data to a WCF Service

A project I was working on recently made use of several WCF services, but we were having trouble sending large amounts of data to them (specifically, large integer arrays). We spent days trying to figure out how to resolve the issue, trying every config param imaginable (maxRequestMessageSize, maxItemsInObjectGraph, etc), but to no avail. Finally, at the 11th hour, one of the developers found the problem: IIS 7 was interpreting this large message as a Denial of Service attack and returning a false error message. The solution was to add the following to the web.config files of the affected services:
  <system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647"/>
</requestFiltering>
</security>
</system.webServer>

Note that the value being used in the maxAllowedContentLength attribute is the maximum integer value and was used only for testing. In practicality, a lower number should be used.

Comments

Anonymous said…
i have a same issue too. i already add maxAllowedContentLength both in wcf service or web web.config but i still got the error message.
What should i do now?
Anonymous said…
Thanks! This helped with a WCF service I created that was returning a 404 error when I passed a long querystring from an AJAX function. (I actually added 'maxQueryString' as well).
Alan said…
Great! Glad to hear this helped. :)

Popular Posts

Resolving the "n timer(s) still in the queue" Error In Angular Unit Tests

How to Get Norton Security Suite Firewall to Allow Remote Desktop Connections in Windows

Silent Renew and the "login_required" Error When Using oidc-client

Fixing the "Please add a @Pipe/@Directive/@Component annotation" Error In An Angular App After Upgrading to webpack 4

How to Determine if a Column Exists in a DataReader