When an unhandled exception occurs in an ASP.NET application one of three types of error pages is displayed:
- The Exception Details Yellow Screen of Death error page,
- The Runtime Error Yellow Screen of Death error page, or
- A custom error page
A Yellow Screen of Death error page is familiar from the points of developers but from the user's point of view this (YSOD) is terrible. To manage the error conditions we configure the custom error page.
There are 2 ways to configure custom error pages for ASP.NET application
web.config file
<configuration>
<system.web>
<customErrors mode="On" defaultRedirect="Error.aspx">
<error statusCode="400" redirect="400.aspx" /> <!--Bad Request-->
<error statusCode="401" redirect="401.aspx" /> <!--UnAuthorize Access-->
<error statusCode="403" redirect="403.aspx" /> <!--Forbidden-->
<error statusCode="404" redirect="404.aspx" /> <!--Not Found-->
<error statusCode="500" redirect="500.aspx" /> <!--Internal Server-->
<error statusCode="503" redirect="503.aspx" /> <!--Service Unavailable-->
</customErrors>
</system.web>
</configuration>
Internet Information Services (IIS) Manager (the GUI)
1.Open Internet Information Services (IIS). select your website and Click on .NET Error Pages icon.


2.Click on Edit Feature Settings link to enable this feature. Then Edit Error Page Settings dialog box will appear.

3. Select the Mode On and enter the customer error page URL in Absolute URL text box. Click OK button.

4.If you want to add the error page based on status code then click on Add link to enable this feature.

5. Enter the Status Code and enter the corresponding URL in Absolute URL text box. Click OK button.

Above steps can also be manage in web.config as
<configuration>
<system.web>
<customErrors mode="On" defaultRedirect="http://www.freshcodehub.com/error.html">
<error statusCode="404" redirect="http://www.freshcodehub.com/404.html" /> <!--Bad Request-->
</customErrors>
</system.web>
</configuration>