Maximum request length exceeded despite config values being set

Jay picture Jay · Aug 8, 2013 · Viewed 10k times · Source

I am having some issues when uploaded files of greater than 4MB to blob storage using an MVC application that I am working on. I have added the necessary code in the web.config as shown below:

Within system.web

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

Within system.webserver

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="1073741824" />
  </requestFiltering>
</security>

I have rebuilt my web project and my azure project but I am still getting the maximum request length exceeded error. Any ideas what might be causing this? Stack trace is as follows:

[HttpException (0x80004005): Maximum request length exceeded.] System.Web.HttpRequest.GetEntireRawContent() +12603644 System.Web.HttpRequest.GetMultipartContent() +221 System.Web.HttpRequest.FillInFormCollection() +357 System.Web.HttpRequest.EnsureForm() +110 System.Web.HttpRequest.get_Form() +16 System.IdentityModel.Services.WSFederationAuthenticationModule.IsSignInResponse(HttpRequestBase request) +32 System.IdentityModel.Services.WSFederationAuthenticationModule.CanReadSignInResponse(HttpRequestBase request, Boolean onPage) +129 System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +152 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

Answer

binard picture binard · May 5, 2014

I had a similar problem, the problem was silly

In my web.config there were already a httpRuntime tag with targetFramework attribute specified.

I created a second httpRuntime tag instead of add maxRequestLength in the already present httpRuntime tag. So my value was ignored.