0

I have an asp.net website (SQL Server, Windows 2003, IIS 6) and I am using google.com/analytics/ to track visits. It all works fine.

Now I would like to use Google Webmaster to get better information about my site but when I try to verify it by uploading a html file I get this error:

"We've detected that your 404 (file not found) error page returns a status of 200 (Success) in the header."

Any ideas - how to fix this?

Charles
  • 50,943
  • 13
  • 104
  • 142
Imageree
  • 4,683
  • 5
  • 26
  • 35
  • For reference: http://stackoverflow.com/questions/347281/asp-net-custom-404-returning-200-ok-instead-of-404-not-found – Bobby Cannon Jan 25 '12 at 21:43

1 Answers1

3

Set the StatusCode of the Response object manually. Put something like this in your 404 page's code behind:

protected override void Render(HtmlTextWriter writer)
{
    base.Render(writer);
    Response.StatusCode = 404;
}
Colin Mackay
  • 18,736
  • 7
  • 61
  • 88
  • By any chance does it also let you verify the site through a meta tag? If so, you might do that instead. – Otis Jul 20 '09 at 22:23