I'm trying to setup a custom error page for the IIS 7 404.13 (Content length too large) error. Here's the relevant sections of my web.config file:

<system.webServer>
  <httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" subStatusCode="13" />
    <error statusCode="404" subStatusCode="13" prefixLanguageFilePath="" path="/FileUpload/Test.aspx" responseMode="ExecuteURL" />
  </httpErrors>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="10240" />
    </requestFiltering>
  </security>
</system.webServer>

The response that is being sent back to the server is blank. The Test.aspx file is not blank.

Any idea what's going on here?

link|improve this question
feedback

4 Answers

That looks correct. Do the IIS logs confirm that a 404.13 error was actually hit? You can test with a standard 404.0 page to confirm that the error pages work as expected. Another way to test that easier is to drop the maxAllowContentLength to a low setting and test with something smaller. That will give you faster feedback in your troubleshooting, and it will confirm that maxAllowedContentLength is the correct setting for the situation that you're testing.

link|improve this answer
I have verified that 404.13 is being returned. It seems like IIS doesn't have the ability to call into the ASP.NET pipeline on errors. I haven't found one example online of someone doing it. Is it even possible? – Nathan Roe May 7 '10 at 12:23
I'm not positive what you're running into, but check this out: serverfault.com/questions/69839/show-php-error-message-on-iis-7/…. That changes how errors are passed through the pipeline. Also, as a test, try adding an ASP.NET error in system.web (rather than system.webServer) and see if you can catch it. – Scott Forsyth - MVP May 7 '10 at 16:06
If 404.13 is returned and the error handler isn't invoked, my guess is that the handler isn't correctly configured, i.e. the path might be wrong as I write in my answer. – asbjornu May 27 '11 at 20:36
feedback

Follow the steps as given here and you should be good.

link|improve this answer
feedback

I'm also getting a blank page (in MVC) when i try to ExecuteURL on a action. It works to use responseMode="Redirect" and setting path as an absolute URL.

See this post: http://stackoverflow.com/questions/2759193/display-custom-error-page-when-file-upload-exceeds-allowed-size-in-asp-net-mvc2/3787284#3787284

MSDN: http://msdn.microsoft.com/en-us/library/ms690497(VS.90).aspx

link|improve this answer
responseMode="Redirect" will first serve a 301 Found and then 200 OK to the browser, which is a very wrong thing to do when what you want to do is respond with 404. – asbjornu May 12 '11 at 7:17
feedback

Have you tried to set a breakpoint within Test.aspx to see if the file is being executed at all? If it is, try setting Response.TrySkipIisCustomErrors to true within your Test.aspx file. If it isn't, your path might be wrong.

For responseMode="ExecuteURL", I've found path to be absolute to the root of whatever domain you've set up your application on, not relative to the application itself. Since the ASP.NET "relative tilde" ~/ is not allowed in path you need to set the full absolute path to the the .aspx file. If your application is found at http://localhost/MyApplication/ you need to set the following:

<error statusCode="404"
       subStatusCode="13"
       path="/MyApplication/FileUpload/Test.aspx"
       responseMode="ExecuteURL" />
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.