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.
Not a direct answer, but found this SO solution worked for me instead of using existingResponse="replace"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With