Nik's Technology Blog

Travels through programming, networks, and computers

404 Error pages Returns code 200

Since a site redesign we've been using a custom 404 ASP page rather than our old HTML 404 page, this gives us the opportunity to add dynamic content to the 404.asp page.

However after setting up Microsoft IIS to serve our custom 404.asp page we discovered to our dismay, using a HTTP header viewer, that the 404 page was returning a code '200 OK' rather than a '404 Not Found'.

After some searching the ASP Response.Status object was found. Now with just one line of code at the top of our ASP 404 page we can set the status to 404 Not Found!

Here's the code.

<%

Response.Status = "404 Not Found"

%>

I've added a link to a handy HTTP viewer below.

http://www.rexswain.com/httpview.html

Comments are closed