Large Message Size And Bad Request on WCF Service

In an application I built, using Silverlight Client and WCF Service, the application threw an exception when the request data passed by the client to the server exceeded about 64K (might be a little bit less).

Using a TCP tracer, I saw that the client received a “bad request” error.

Looking around a little bit, the solution was quite easy.

When creating a service reference in the Silverlight project using Visual Studio, the ServiceClient.config already contains the maxBufferSize and maxReceivedMessageSize properties.

What is missing are the corresponding settings in the WCF Services’s web.config. So just put a

<binding maxBufferSize="2147483647"

section inside the system.serviceModel node, and you’re done 🙂