User and search engines have different preferences regarding files that are not found. Users like nice error pages telling them how to find the content requested, while search engines depends on statuscodes in the response. Configuring ASP.NET to create friendly error pages seems to have some issues regarding the statuscodes sent back to the browser.
ASPX files that are not found will be handled by the ASP.NET framework and not by IIS. If you are using customErrors in web.config the user will be redirected to a custom error page which is really nice, but the response to the browser will be 302 (redirect) and not 404. I guess the search engines does not notice that this is a page which is not found.
Non ASPX files (badfile.htm) will be handled by IIS and it is possible to configure IIS to display a custom page for files not found, but IIS will return a 200 statuscode to the browser, not a 404.
So, how can I achieve to display friendly 404 pages to the user that returns 404 statuscodes to the browser for both ASP.NET and non-ASP:NET files?