IIS Custom 404 Page Gives 200 Response Code

I’m working on a website that uses IIS and needs a custom 404 page created. I made 404.aspx and added the following code to my web.config file

<customErrors mode="On" redirectMode="ResponseRewrite">
	<error statusCode="404" redirect="404.aspx"/>

It does work (nonexistantpage.aspx shows the contents of 404.aspx) but when I check the header response code, I see a 200 instead of a 404 (a big SEO no-no). Any ideas on how I make it show the correct error response code?


Found the fix… need to add the following code to the top of 404.aspx

<% Response.Status = "404 Not Found" %>

The better way is to use the errors bits under system.webServer if you are on IIS7 – those will spit back proper http codes without adding it to the script.