web analytics

Turn off Asp.net Custom Errors in Web.config

Options

codeling 1595 - 6639
@2016-12-14 09:00:10

In asp.net, we can find the exact error message by setting mode="Off" with in customErrors tag in web.config of our application.

 

To show the detailed message for the unexpected error, you have to create a <customErrors> tage in the Web.config:

<system.web>

<customErrors mode="Off">

</customErrors>

...

...

</system.web>

In Asp.net, there are three error modes to trace an error. These modes decide whether or not an error message is displayed. RemoteOnly mode is default mode for displaying error messages.

Off Mode

This mode is responsible for displaying error mesage on local and remote server in case of an error.

On Mode

This mode is responsible for displaying custom error page with message on local and remote server in case of an error. By using this mode, we can show our own custom error messages page for specific errors on local and remote server.

RemoteOnly

This mode is responsible for displaying error mesage on remote server only in case of an error. By using this mode, we can show our own custom error messages page for specific errors on remote server only.

@2016-12-14 09:07:28

customErrors Element

<customErrors defaultRedirect="url"
              mode="On|Off|RemoteOnly">
     <error. . ./>
</customErrors>
Attribute Description

defaultRedirect

Optional attribute.

Specifies the default URL to direct a browser to, if an error occurs. When this attribute is not specified, a generic error is displayed instead.

The URL can be absolute (for example, www.contoso.com/ErrorPage.htm) or relative. A relative URL, such as /ErrorPage.htm, is relative to the Web.config file that specified the URL for this attribute, not to the Web page in which the error occurred. A URL starting with a tilde (~), such as ~/ErrorPage.htm, indicates that the specified URL is relative to the root path of the application.

mode

Required attribute.

Specifies whether custom errors are enabled, disabled, or shown only to remote clients.

This attribute can be one of the following values.

 
Value Description

On

Specifies that custom errors are enabled. If no defaultRedirect attribute is specified, users see a generic error. The custom errors are shown to the remote clients and to the local host.

Off

Specifies that custom errors are disabled. The detailed ASP.NET errors are shown to the remote clients and to the local host.

RemoteOnly

Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value.

The default is RemoteOnly.

 

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com