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.