Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3:Maximum request length exceeded

Here is the context:

ASP MVC3 - IIS 7

I am using ElMah configured very well as documented nearly everywhere for MVC. And it is working.

Here is what I have in my config file

  <system.web>
    <httpRuntime maxRequestLength="1024" enableVersionHeader="false" />
    <customErrors mode="On" defaultRedirect="~/Error/Generic" />
    ...
     <system.webServer>
        <httpErrors errorMode="Detailed" existingResponse="PassThrough" defaultPath="~/Error/Generic" defaultResponseMode="ExecuteURL"></httpErrors>

Now here is my problem I spent the whole day trying to catch this error : "Maximum request length exceeded" when I submit a file that exceed 1024 bytes

Between asp errors and IIS errors and sometimes IE interception, I'am getting crazy I cannot understand why this is so complicated. I already tried these solutions and none worked for me solution 1 Solution 2

Thank you for your help

like image 236
user385411 Avatar asked Apr 14 '11 16:04

user385411


People also ask

What does Maximum request length exceeded mean?

Large file uploads in ASP.NET The default maximum filesize is 4MB - this is done to prevent denial of service attacks in which an attacker submitted one or more huge files which overwhelmed server resources. If a user uploads a file larger than 4MB, they'll get an error message: "Maximum request length exceeded."

What is MaxRequestLength?

The MaxRequestLength property specifies the limit for the buffering threshold of the input stream. For example, this limit can be used to prevent denial of service attacks that are caused by users who post large files to the server.


1 Answers

When setting maxRequestLength to 1024 this means 1024 kilobytes, not 1024 bytes. Maybe this is why the exception isn't thrown.

like image 153
Robin van der Knaap Avatar answered Dec 15 '22 07:12

Robin van der Knaap