404 Redirect to Custom Page

The 404 or Not Found error message is a HTTP Standard Response Code indicating that client was able to communicate with the server but the server could not find what was requested.

we can handle Error Code 404 in several ways.

There are three places in ASP.NET to define what happens to these unhandled errors.


  • In web.config file, Custom Error section of <system.web>
<customErrors mode="On" defaultRedirect="Error.html">
       <error statusCode="500" redirect="Error500.html">
       <error statusCode="401" redirect="Error401.html" />
       <error statusCode="404" redirect="Error404.html" />
      <error statusCode="403" redirect="Error403.html" />
</customErrors>
  • In global.asax file, Application_Error method.

  • In code-behind file, Page_Error method.

Comments

Popular posts from this blog

Data Bound Controls in ASP.Net - Part 4 (FormView and DetailsView controls)

ASP.net: HttpHandlers

The Clickjacking attack and X-Frame-Options