In my asp.net web site I have custom error pages defined as following in my web.config file.
In ASP.NET 4.0 you can use redirectMode="ResponseRewrite" to send nice error pages and the proper HTTP code.
redirectMode="ResponseRewrite"