As we all know, when developing an asp.net application, you can use the web. config file to configure the ASP. NET
Display information. The following is a typical basic configuration:
<System. web> <customErrors mode = "On" defaultRedirect = "GenericErrorPage.htm"> <! -- The resource is unavailable. The server understands the client request, but rejects the request, for example, the web request. config file --> <error statusCode = "403" redirect = "NoAccess.htm"/> <error statusCode = "404" redirect = "FileNotFound.htm"/> </customErrors> </system. web>
The preceding mermerrors is the configuration node for custom errors. It has two important attributes: mode and defalutRedirect.
The following is the description on MSDN:
Custom errorOr, disable the detailed error message when you view an error on a computer other than the server itself.
You can set the mode to the following values:
On specifies to enable custom errors. If the defaultRedirect feature is not specified, you will see it. A custom error is displayed to the remote client and local host.
Off specifies to disable custom errors. It is displayed to the remote client and local host.
RemoteOnly indicates that only custom errors are displayed to the remote client and detailed ASP. NET errors are displayed to the local host. This is the default value.
DefaulRedirect specifies the default URL to which the browser directs when an error occurs. If this feature is not specified, a general error is displayed.
The preceding descriptions contain three types of errors: Custom errors, General errors, and detailed asp.net errors.
What are these three types of errors? The following is a simple example.
1) if mode is set to Off, disable custom errors and display detailed ASP. NET errors to remote clients and local hosts.
If the defaultRedirect feature is not specified, you will see a general error.
We remove the defaultRedirect attribute and set mode = On. In this example, If you enable custom error display, but the denominator is 0
The Processing Method of ASP. NET. As shown in:
.
3) If mode = On is set, a custom error is enabled. If defaultredirect1_genericerrorpage.htm is specified, a custom error is displayed.
.
Similarly, we can specify how asp.net displays custom pages when the accessed file does not exist or has no permission to access the current page. You can use the error subitem
Node. For example:
<error statusCode= redirect= /><error statusCode= redirect= />
Here, we only briefly describe commonly used information in custom error configurations. For more information about configuration nodes, see MSDN.