Default redirect for Error 404

This is how you configure a custom 404 error page for both ASP.NET and non-ASP.NET requests:


      <compilation targetFramework="4.0" />

      <customErrors mode="On" redirectMode="ResponseRewrite">
         <error statusCode="404" redirect="http404.aspx" />

      <httpErrors errorMode="Custom">
         <remove statusCode="404"/>
         <error statusCode="404" path="/http404.aspx" responseMode="ExecuteURL"/>


As others already pointed out, you should not use an HTTP redirection to send the user to the home page, this is not only confusing to users but also to machines (e.g. search engines). It is important to use the 404 status code and not a 3xx code.

You can achieve the desired functionality using meta refresh on HTML:

<%@ Page Language="C#" %>

<html xmlns="">
   <title>Not Found</title>
   <meta http-equiv="refresh" content="5;url=/"/>
   <h1>Not Found</h1>
   <p>Redirecting to Home...</p>

Leave a Comment