I want all URLs of missing pages to forward to my 404 page which is in my root as 404error.aspx
So far only the UR
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>
The settings in the example customErrors section cause any unhandled HTTP 404 (file not found) errors to be directed to the Http404ErrorPage.aspx file. These HTTP 404 errors would occur if a request were made for an .aspx file, .asmx file, and so on and if the requested file did not exist. All other unhandled errors in ASP.NET files are directed to the DefaultRedirectErrorPage.aspx file.
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true" />
<!-- Turn on Custom Errors -->
<customErrors mode="On"
defaultRedirect="DefaultRedirectErrorPage.aspx">
<error statusCode="404" redirect="Http404ErrorPage.aspx"/>
</customErrors>
</system.web>
</configuration>
NoteNote: In the example, the mode attribute is set to "On" so that you can error messages when you run the example in Visual Studio. In a production environment, this setting would normally be "RemoteOnly". ASP.NET then renders error pages to external users. If a request is made on the server computer (localhost), ASP.NET renders a page with detailed error information.