I've just noticed something rather annoying about custom error pages. Wanting to show users a nice message when they try to load a non-existent aspx page I set my web.config up like this:
After having done this I then loaded up Fiddler to see what happens when I access a non-existent aspx page. It turns out that what you get is this:
1. A 302 Found response from the URL that is missing and
2. A 200 OK response from Error404.aspx
The trouble is that I have a number of search engines that keep scanning my site and indexing my error page where they could not find files. I can't remove all the links to these missing files as they are from other sites.
Does anyone know how I can give a nice friendly error message to users of my site and still return a 404 Error code in the Http header without the 302 step?
Code:
<configuration>
<configSections>
<system.web>
<customErrors mode="On" defaultRedirect="Error.aspx">
<error statusCode="404" redirect="Error404.aspx" />
</customErrors>
</system.web>
</configSections>
</configuration>
1. A 302 Found response from the URL that is missing and
2. A 200 OK response from Error404.aspx
The trouble is that I have a number of search engines that keep scanning my site and indexing my error page where they could not find files. I can't remove all the links to these missing files as they are from other sites.
Does anyone know how I can give a nice friendly error message to users of my site and still return a 404 Error code in the Http header without the 302 step?