I have created a RESTful POST web service in ASp .net C# with IIS hosting the service.
My service accepts an XML file as input and when the size exceeds 65KB I get the following error message:
The remote server returned an error: (400) Bad Request.
my question is two fold, first is there a default limit set by the IIS server for POST requests and secondly how can I update this?
Many Thanks
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
John Källén’s answer was correct, but in my case I had an end point defined so setting the maxReceivedMessageSize had to be as follows:
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name=""
helpEnabled="true"
automaticFormatSelectionEnabled="true"
maxReceivedMessageSize="2147483647">
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
Method 2
Have you tried adding the following to your web.config?
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1000000" />
</requestFiltering>
</security>
<system.webServer>
This will bump up your allowed content length to a megabyte. Also, you may want to set the maxReceivedMessageSize attribute of your WCF bindings to more than the default 64k:
<webHttpBinding>
<binding name="MessageSizeWeb" maxReceivedMessageSize="2147483647" />
</webHttpBinding>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0