Reputation: 6145
I have a large chunk of json that I need to post to a self hosted ASP.Net Web API Service.
I get the "Status Code:413 Request Entity Too Large" message.
Tried to put the following in the app.config of the webapi service project.
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
<httpRuntime
maxRequestLength="2147483647"
executionTimeout="300" />
</system.web>
This didn't help.
I am thinking about the following two options.
I prefer the 2nd option, but have not yet found how to make it happen.
Any pointers?
Upvotes: 17
Views: 10609
Reputation: 456
I was getting the same problem and was able to make the change in code.
var config = new HttpSelfHostConfiguration(host);
config.MaxReceivedMessageSize = 2147483647; // use config for this value
/*
other setup for the config
*/
using (var server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
Console.WriteLine("Insight.Web");
Console.ReadLine();
}
Upvotes: 18