If you understand correctly, you want to handle 404 Not Found errors, processed without re-writing the URL and just returning a representation of the result
One way to achieve this is to use the old customErrors , but with redirectMode="ResponseRewrite" , to ensure that the original URL is not changed.
<customErrors mode="On" redirectMode="ResponseRewrite"> <error statusCode="404" redirect="~/NotFound" /> </customErrors>
Another is to use the httpErrors method with existingResponse="Replace" Just like you use it over time
<system.webServer> <httpErrors errorMode="Custom" existingResponse="Replace"> <clear/> <error statusCode="404" path="/Errors/NotFound.html" responseMode="ExecuteURL"/> </httpErrors> </system.webServer>
I tried to recreate your problem and succeeded only when I had httpErrors and customErrors set without redirectMode="ResponseRewrite"
My conclusion: you are probably using customErrors without ResponseRewrite , which takes precedence over the httpErrors handler.
source share