CustomError mode in web.config file

Create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

 

<!-- Web.Config Configuration File -->
 
<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

 

When customErrors is set to On or RemoteOnly, you need to specify the defaultRedirect attribute. This attribute contains the error page to which the user will be redirected. Additionally you can take custom error handling a step further by associating specific errors with specific error pages. The customErrors section can contain error elements that associate particular errors with error pages. The following code sample illustrates this concept.

 

<?xml version="1.0"?>

  <configuration>

     <system.web>

 <customErrors mode="RemoteOnly" defaultRedirect="Contents/CommonPage.aspx">

      <error statusCode="403" redirect="Contents/CommonPage.aspx" />

      <error statusCode="404" redirect="Contents/CommonPage.aspx" />

    </customErrors>

     </system.web>

  </configuration>

Ebook Download
View all
Learn
View all