In a old site, I was changing the way that CustomErrors works by adding redirectMode=\"ResponseRewrite\"
(new in 3.5 SP1):
What's happening is IIS is seing the error status code and presenting it's own error page instead of yours. To solve you need to set this in the code behind page of your error page to prevent IIS from doing this:
Response.TrySkipIisCustomErrors = true;
This will only work in IIS7 or above, for earlier versions of IIS you'll need to play with the error page settings.