How do I configure the buffer size and max message size in the ASP.NET Web API

suing picture suing · Feb 26, 2012 · Viewed 30.1k times · Source

We used to have these properties in the WCF Web API configuration.

            MaxBufferSize = int.MaxValue,
            MaxReceivedMessageSize = int.MaxValue,

Answer

Justin Saraceno picture Justin Saraceno · Feb 26, 2012

If you're self-hosting, it's part of the HttpSelfHostConfiguration class: MSDN Documentation of the HttpSelfHostConfiguration class

It would be used like this:

var config = new HttpSelfHostConfiguration(baseAddress);
config.MaxReceivedMessageSize = int.MaxValue;
config.MaxBufferSize = int.MaxValue;