Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpErrors existingResponse="Replace" prevents custom error handling for MVC

I'm handling errors using the [HandleError] attribute from within an MVC3 application. This works fine but for this to work, I needed to add

<system.web>
     <customErrors mode="On" />

To handle 404 errors, I then added this to system.webserver i.e. IIS config rather than asp.net

<httpErrors errorMode="Custom" existingResponse="Replace">
   <remove statusCode="404" />
   <error statusCode="404" responseMode="ExecuteURL" path="/404page" />
</httpErrors>

This is simple and works great for 404's. The reason for adding this here is that it seems like a good catch-all without any custom code. The existingResponse="Replace" is required, other modes result in 404's not being handled.

The problem is that when existingResponse="Replace" the CustomErrors not longer functions. It just returns a stripped 500 error without details.

Are these two modes just mutually exclusive? I am aware that I can code other 404 solutions, but ideally I'd like this simple config change to work or understand why it just can't be done.

like image 328
Paul George Avatar asked Jul 12 '12 14:07

Paul George


1 Answers

Not a direct answer, but found this SO solution worked for me instead of using existingResponse="replace"

like image 82
Paul George Avatar answered Oct 14 '22 04:10

Paul George