Using web.config you can force IIS to answer with a custom error page.
Please refer to this page (https://stackoverflow.com/questions/257 ... aspx-pages) for more information
You need to configure the <httpErrors> element. This configures the error pages for both static files and server pages.
Your 3rd attempt "web.config (3)" and "Edit 1" are almost there. The problem is that you can't use app-relative paths here (ex: "~/404.html"), they have to be relative from the site root (ex: "/404.html").
<?xml version="1.0"?>
<configuration>
<system.webServer>
<httpErrors>
<remove statusCode="401" subStatusCode="-1" />
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<!-- full url when responsemode is Redirect -->
<error statusCode="401" path="http://foo.com/default.htm" responseMode="Redirect" />
<!-- local relative path when responsemode is ExecuteURL -->
<error statusCode="403" path="/404error.aspx" responseMode="ExecuteURL" />
<error statusCode="404" path="/404error.aspx" responseMode="ExecuteURL" />
<error statusCode="500" path="/404error.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>