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 from this blog

A Generic Method Using HttpClient to Make a Synchronous Get Request

The Cause and Solution for the "System.Runtime.Serialization.InvalidDataContractException: Type 'System.Threading.Tasks.Task`1[YourTypeHere]' cannot be serialized." Exception

"$.ajax is not a function" Error When Using jQuery and Darren Johnstone's ASP.NET Upload/Download Module v2