Does Your 404 404?
Remember my awesome custom 404 page built using Graffiti's Chalk theme engine? I found out today (thanks to Google's webmaster tools) that it had a problem - it was actually returning HTTP/200 (OK) as its response code. That meant that any robot visiting an address on my site that doesn't exist would actually believe that the page does exist, which is not ideal.
After searching around fruitlessly for a way to change the http response code from Graffiti, I decided to write my own Chalk extension to do it for me.
Essentially I've created a new class with a method called SetResponseStatusCode, which takes an int parameter. It grabs the current HttpContext and sets its Response.StatusCode to the given value. I then added this code to my custom 404.layout.view file:
$Props.SetResponseStatusCode(404)
Now my 404 page really does 404, so that's good to know. Worth checking if you've taken the time to provide a custom page of your own.
# Trackback from Graffiti 404 Manager on 1/02/2009 1:54 PM
# Trackback from Graffiti 404 Manager on 3/02/2009 4:21 AM
Comments
# DougC
18/10/2008 4:27 AM
Hey Matt - I posted a response to you post over at support.graffiticms.com/.../3698.aspx and then I realized you may not be monitoring that site. Was hoping you could share the code for your Chalk extension. Many thanks.