I have this code in my web.config file:
<customErrors defaultRedirect="~/GeneralError.aspx" mode="On">
<error statusCode="401" redirect="401.aspx" />
<error statusCode="404" redirect="404.aspx" />
</customErrors>
This works perfectly on my local machine while running IIS and it redirects to my error pages, however when I run it on the server, IIS’s default error pages pop in instead of mine.
Why is this? How can I fix this? Is this something related from the code, or is this some setting on the server?
This may not be the right solution for your issue, but double check IIS settings (Error Pages)
http://blogs.iis.net/rakkimk/archive/2008/10/03/iis7-enabling-custom-error-pages.aspx
IIS error pages settings override application config.