How to increase maxReceivedMessageSize and maxBufferSize parameters in app.config file to 2000000 before running the application.
7 Answers
You need to do that on your binding, but you'll need to do it on both Client and Server. Something like:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferSize="64000000" maxReceivedMessageSize="64000000" />
</basicHttpBinding>
</bindings>
</system.serviceModel>

- 55,877
- 15
- 127
- 148
-
Thanks @mattytommo,this is what i wanted. – Vishal I P Feb 21 '13 at 12:47
-
Thank you! It works for me as well. It works even when I provide this change for client only. – Sergey Sep 24 '14 at 11:04
-
perfect, you saved me a lot of time :) ++1 – Dan Dinu Oct 09 '14 at 19:29
-
1I don't get why this answer has so many upvotes. It is wrong, you are not required to set those values on both the client and the server. See my answer below. – D.R. Nov 22 '16 at 14:35
-
Your little bold words are life-saving. Thanks! – kerbasaurus May 24 '17 at 18:01
You can do that in your app.config. like that:
maxReceivedMessageSize="2147483647"
(The max value is Int32.MaxValue
)
Or in Code:
WSHttpBinding binding = new WSHttpBinding();
binding.Name = "MyBinding";
binding.MaxReceivedMessageSize = Int32.MaxValue;
Note:
If your service is open to the Wide world, think about security when you increase this value.

- 98,240
- 88
- 296
- 433

- 751
- 1
- 6
- 18
The currently accepted answer is incorrect. It is NOT required to set maxBufferSize
and maxReceivedMessageSize
on the client and the server binding. It depends!
If your request is too large (i.e., method parameters of the service operation are memory intensive) set the properties on the server-side, if the response is too large (i.e., the method return value of the service operation is memory intensive) set the values on the client-side.
For the difference between maxBufferSize
and maxReceivedMessageSize
see MaxBufferSize property?.

- 20,268
- 21
- 102
- 205
-
I'm not sure why we have to bother to set the limits at all. What if I don't know how large a payload's going to be (think cardinalities of 0..n)? – René Schindhelm Mar 20 '19 at 17:23
-
You should always have a protection against "too large". Otherwise you're wide open to DoS attacks. – D.R. Mar 21 '19 at 07:22
-
Safety aside (which really shouldn't be neglected for public facing services), you won't know at compile-time the amount of data you might send or retrieve from a service call (think object graphs f.e.). You can only estimate. I think [Large Data and Streaming](https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/large-data-and-streaming) is of interest, especially the chapter "Special Security Considerations for Large Data". – René Schindhelm Apr 10 '19 at 20:13
If you are using a custom binding, you can set the values like this:
<customBinding>
<binding name="x">
<httpsTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>

- 71
- 2
- 11
Open app.config on client side and add maxBufferSize and maxReceivedMessageSize attributes if it is not available
Original
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Soap"/>
</basicHttpBinding>
</bindings>
After Edit/Update
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Soap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
</basicHttpBinding>
</bindings>

- 1,762
- 15
- 25
Easy solution: Check if it works for you..
Goto web.config
Find binding used by client.
change as,
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
Done.

- 149
- 4
- 13
binding name="BindingName"
maxReceivedMessageSize="2097152"
maxBufferSize="2097152"
maxBufferPoolSize="2097152"
on client side and server side

- 13,575
- 26
- 81
- 144