I have an older ASP.NET API web service using .net 4.5.2 and I am posting an object that contains a base64 image to my controller without any problem. The issues come now when I try to post data with more and larger images and I am getting the 413 request entity too large error. I have been looking up things and tried everything I could find on the net with no luck. I am looking to upload files about 10MB in size. One thing that leads me to believe its server related is when running the service under IIS Express I can upload large files locally.
I have tried adding MaxRequestLength and MaxAllowableContentLength to the web config.
<system.web>
<!-- tell IIS to let large requests through -->
<httpRuntime maxRequestLength="52428800" />
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
I have also made a change on my windows 2012 R2 server in IIS v6.2 to allow larger files. I have also adjusted the UploadReadAhead value on the server.
I don't have anything special in API config class.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
}
}
The bindings in my config for this service
<webHttpBinding>
<binding name="SecureServerBindingWithUserNameRest" maxReceivedMessageSize="52428800">
<readerQuotas maxArrayLength="10485760" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" proxyCredentialType="None" />
</security>
</binding>
<binding name="webHttpTransportSecurityRest">
<security mode="Transport" />
</binding>
</webHttpBinding>