I have a piggy back question off of @Mike C's question I have implemented what is in @rsbarro's answer. The asp.net custom error works fine, it's the IIS custom errors which doesn't want to work for me. I've found that the only way it wants to work is if I set the error to redirect to the custom 404 page, however, that's less than ideal since I need the original requested url. Below is what I have in my web.config.
For asp.net Custom Error Pages:
<customErrors mode="On">
<error statusCode="404" redirect="/404.aspx" />
<error statusCode="500" redirect="/500.aspx" />
</customErrors>
The above works just fine. And for IIS Custom Errors (which does not work).
<system.webServer>
...
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/auto404.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
Running IIS7 in a classic app pool (can't use integrated because of Sitecore CMS), any ideas?