Asp. NET error page

Source: Internet
Author: User
Tags system log

When the page error occurs, ASP. NET will show the error message, which is not good, and will reveal the inside of the site
Implement information that poses a security risk to your site, so you need to customize the error page and display developer-customized pages when errors occur
404 pages It's good to put some ads.
Configure Web. config, configure the customerrors zone:

<customerrors mode= "on" defaultredirect= "myerrorpage.aspx" >    <error statuscode= "403" redirect= " Noaccess.htm "/>    <error statuscode=" 404 "redirect=" filenotfound.htm "/>  

Mode three selectable values:

On: Always display the custom error page;

OFF: Do not display the custom error interface, directly display the call stack and other exception information;
Remoteonly: For native access to display exception information such as Call stack, for external user display custom error page

Generally set to remoteonly, so that if an error occurs, the administrator can see the detailed error message in the server's browser,
Not visible to ordinary users. When you learn the demo, mode is set to ON, otherwise you can't see the custom page. You can determine in the definition error page
Request.userhostaddress to set some IP to see the exception information, can read the session if the administrator can see the exception information

Error sub-element settings for different status codes using different bug pages, many websites make 404 a special error page
A status code error that is not set individually displays the page specified in the defaultredirect
You can use the HTM page for the error page, or you can use the ASPX page
You can use HttpContext.Current.Server.GetLastError () to get the exception object in the ASPX page.
Generally do not display the exception information to the user, but use the following log4net, etc. to record the exception to the system log.
If you want to get the exception object in the error page, you must set redirectmode= "Responserewrite" in customerrors.
Because the default is client-side redirection, the exception object is not taken on the error page

Asp. NET error page

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.