Reputation: 1545
What web.config settings should I enter so that I can handle 404 errors but not other errors. The reason I want to handle 404 errors is that sometimes I purposely enter urls for inexisting pages but which I can handle and internally redirect to the real pages. That works fine, however, I do not want to handle other pages. On the contrary, I want to load the standard "non-custom" errors so that I can identify what is wrong with the page and see the line number causing the error. But when I enable custom errors for 404, I start getting redirected to the default error page (for 500 errors) and not have a clue of what caused the error.
Alternately I would consider having a custom error page that properly displays which page and which line is causing the error. I could do that for classic ASP but I could not find how to do that for ASP.Net.
Any help or pointers would be greatly appreciated.
Thanks!
P.S. not sure if it makes a difference, but my test server is IIS7.5 while the one for the live website is IIS6.
Upvotes: 1
Views: 809
Reputation: 8818
Try this:
<httpErrors errorMode="Custom" existingResponse="Replace"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" path="/Errors/404.aspx" responseMode="ExecuteURL"/> </httpErrors>
Please refer to the following post: http://tedgustaf.com/en/blog/2011/5/custom-404-and-error-pages-for-asp-net-and-static-files/
Upvotes: 4