1

Possible Duplicate:
Maximum request length exceeded

I'm using IIS 6 to host my Asp.net site. I'm having

"Maximum request length exceeded."

error. I fixed it on IIS 7 but on IIS 6, Asp.net error triggers before going into the Global.asax Application_Error. I'm just redirecting to a custom error page in Application_Error. Please let me know what I'm missing here.

Here is the fix I used in IIS 7 webconfig

<system.webServer>
<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="100000" />
  </requestFiltering>
</security>
<httpErrors errorMode="Custom" existingResponse="Replace">
  <error statusCode="404" subStatusCode="13" prefixLanguageFilePath="" path="UploadError.aspx" responseMode="Redirect" />
</httpErrors>

The solution above won't work on IIS 6! I need to do it in Application_Error on Global.asax. Which is not triggering before Maximum request length exceeded.

Community
  • 1
  • 1
HardCode
  • 2,025
  • 4
  • 33
  • 55
  • 1
    did you change in web.config? http://stackoverflow.com/questions/3853767/maximum-request-length-exceeded – Alexan Jan 14 '13 at 17:28
  • What was the fix for IIS7? You can increase the maximum request length with some simple changes to the web.config. – Cᴏʀʏ Jan 14 '13 at 17:28
  • Well, yes I know I could change the file size limitation. But I want to show the custom error message instead of asp.net default error. – HardCode Jan 14 '13 at 17:31
  • @HardCode: You may want to rephrase your question. Nowhere in your post do you state that your intentions are to trap and display the error. – Cᴏʀʏ Jan 14 '13 at 19:24
  • @Cory: Application_Error explains itself! and I think it's a valid question. – HardCode Jan 14 '13 at 19:29

2 Answers2

2

This is a duplicate of: Maximum request length exceeded

This thread contains the solution for both IIS6 and IIS7 on handling maximum request length exceptions

For redirecting to custom error pages, in your Web.Config, use the following:

<configuration>
...

    <system.web>
        <customErrors mode="RemoteOnly"
                  defaultRedirect="~/ErrorPages/Oops.aspx" />

    ...
    </system.web>
</configuration>

where "~/ErrorPages/Oops.aspx" is the path to your error page.

Community
  • 1
  • 1
d3v1lman1337
  • 229
  • 1
  • 10
1

Besides the security block you would also need to change the system.web\httpRuntime which has a maxRequestLength attribute.

 <httpRuntime maxRequestLength="8192" />

More on msdn

faester
  • 14,886
  • 5
  • 45
  • 56