ASP 3.0 advanced programming)

Source: Internet
Author: User
7.4.4 IIS error page
The content related to ASP error handling process is to provide custom error pages for IIS. In fact, this feature also exists in IIS 4.0. However, the new ASP built-in object ASPError is easier to use and provides more powerful functions.
In Chapter 4th, when studying the Server. Execute and Server. Transfer methods, we have already discussed how to create custom error pages. We also discussed and used the ASPError object, but this method is limited. This section describes how to combine custom error webpages with ASPError objects to create a better way to handle ASP errors.
You can use VBScript to check the content of the ASPError object to create a custom error page. Construct a string containing the full error content and write it to the log file on the server disk. However, the design of a webpage does not work if the visitor sees that the webpage is unavailable. The visitor should be able to choose whether to reload the webpage or return to the homepage, they are unaware that an error has occurred.
Although we use VBScript to create this webpage, some of its features are also applicable to JScript, and the conversion between these two scripting languages is also easier.
You can download sample files for this chapter and other chapters of this book from the http://www.wrox.com site.
1. Set custom error pages
Before you can use a custom error page, you must set it in Internet Services Manager (see Chapter 4th for the setting method ). Load the sample file into the wwwroot Directory of the computer, open the Properties dialog box in the Chapter07 subdirectory, scroll down the list on the Custom Errors tab, and select the HTTP error "500: 100" entry, click the Edit Properties button and enter the custom error page Custom_error.asp URL, as shown in Figure 7-17:
Figure 7-17 Custom Errors tab
When an ASP error occurs on the page in the Chapter07 subdirectory, the custom error page is displayed.
2. Use custom error pages
Open the Chapter07 directory in the browser and select the "Using a Custom Error Page" link. This Page displays a series of buttons used to generate various types of errors, click the button marked with "Load a Page with a Syntax error", as shown in Figure 7-18:
Figure 7-18 shows Screen 1 of the custom error page
This will load a simple page named syntax_error.asp. However, you cannot see this page because it contains a syntax error. ASP terminates the compilation/execution of this page and transfers the execution to the custom error page. The page displays the error details and two buttons, which are used to return to the previous page (main menu) or return to the default homepage of the Web site, as shown in Figure 7-19:
Figure 7-19 demonstrate Screen 2 of the custom error page
This page also appends the error report to the log file custom_error.log in the C: emp folder on the server disk. You can open it in the file editor and view it, the log file shown in Figure 7-20 has recorded several errors.

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.