Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customer Error Pages give incorrect Http Error Codes

Status
Not open for further replies.

Aptitude

Programmer
Feb 14, 2003
187
0
0
GB
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:
Code:
<configuration>
  <configSections>
    <system.web>
      <customErrors mode="On" defaultRedirect="Error.aspx">
        <error statusCode="404" redirect="Error404.aspx" />
      </customErrors>
    </system.web>
  </configSections>
</configuration>
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top