An unfriendly 404 error occurs whenever the user accesses the error page, so in order to prevent this unfriendly, we configure the <CUSTOMERRORS> under the <system.web> node in Web. config, in the presence of example 403 404 such errors, jump to our custom page
<customerrors>: User error configuration section
This configuration section allows you to specify that when an error occurs, the system automatically jumps to a page where the error occurs, and can also configure the application to support custom errors. The <customErrors> configuration section consists of two properties, both mode and defaultredirect. The mode includes 3 states, the three States are on, off, and RemoteOnly. On indicates a custom error is initiated; off means no custom error is started; remoteonly indicates that a custom error is displayed to the remote user. In addition: The Defaultredirect property configures the page to jump when an application error occurs.
The <customErrors> configuration section also includes a sub-configuration section "<error>", which is used for custom error pages in a specific state, and the child tag "<error>" includes two attributes. StatusCode and redirect respectively, where statuscode is used to catch the status code where the error occurred, and redirect specifies the page to jump after the error occurs, as shown in the configuration section Configuration code.
<customerrors mode= "RemoteOnly" defaultredirect= "genericerrorpage.htm" >
<error statuscode= "403" redirect= "noaccess.htm"/>
<error statuscode= "404" redirect= "filenotfound.htm"/>
</customErrors>
The code above is configured with the appropriate customerrors information in the Web. config file. When a 404 error occurs, the system jumps to the Filenotfound.htm page to prompt for 404 errors, and developers can write filenotfound.htm pages for user prompts
Jump to specify error page after configuring page error in Web. config