HttpException: maximum request length exceeded, even when config has values that should allow it

0

I can't seem to allow a 4.3MB upload. I keep getting this error:

System.Web.HttpException (0x80004005): Maximum request length exceeded.

My web.config settings in my Web API:

<!-- maxRequestLength expresses POST buffer size in KB. This is the ASP.NET limit. -->
<httpRuntime targetFramework="4.5" maxRequestLength="20000" />

<!-- Let this be larger than maxRequestLength so we get ASP.NET error (if request too large) instead of IIS error. -->
<requestLimits maxAllowedContentLength="20480000" />

And this is the call to the API from my web project:

var response = await httpClient.SendAsync(proxyRequest);

That always returns the above error. What am I missing? I did read where maxRequestLength needs to be the same value as maxAllowedContentLength, but that didn't work either.

c#
asp.net
iis
asp.net-web-api
asked on Stack Overflow Sep 19, 2018 by Bob Horn

1 Answer

0

The "Default Web Site" in IIS had a config file with almost nothing in it. I added maxRequestLength="20000" to it and it worked. My app is one of many apps under "Default Web Site."

Added this:

  <system.web>
    <httpRuntime targetFramework="4.5" maxRequestLength="20000" />
  </system.web>
answered on Stack Overflow Sep 20, 2018 by Bob Horn

User contributions licensed under CC BY-SA 3.0