Jump to specify error page after configuring page error in Web. config

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.