When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Friday, January 07, 2000

A Look Ahead to ASP 3.0, Part 2

  • Read Part 1

    - continued -

    In Part 1 we looked at the two new methods of the Server object: Execute and Transfer. Also new to ASP 3.0 is a brand new intrinsic object, the ASPError object.

    ASPError Object (view the technical docs) - This new, intrinsic object provides a graceful error handling not available in earlier versions of the ASP engine. Previously, handling ASP errors was impossible. You could catch scripting errors using VBScript's On Error Resume Next, or using JScript's try ... catch blocks, but you could not trap errors that occurred in COM objects, or intrinsic ASP errors. That has all changed with the advent of the ASPError object.

    To utilize this object, first you need to customize the custom HTTP errors within IIS. When an ASP-related error occurs, the HTTP error 500;100 is triggered. In IIS 4.0 you can trap HTTP errors, and, when they occur, you can have an ASP script execute. (See Creating a Custom 404 Error Page for information on how to trap the HTTP 404 Error using IIS 4.0.) With IIS 5.0, you can trap the 500;100 HTTP error, and, when it occurs, have the user redirected to an ASP script.

    This ASP script can access the ASPError object to determine the specifics of the error that just occurred. The ASPError object has a number of read-only properties that reveal detailed information on the last error. The Server object contains a new method, GetLastError, which must be used to obtain the information on the latest ASP error. The GetLastError method returns an instance of the ASPError object.

    So, imagine that you created a default error handling script titled CatchError.asp. You would need to setup your IIS web server such that when an HTTP 500;100 error occurred, the user was redirected to CatchError.asp. Then, to display the detailed information of the error that just occurred, CatchError.asp could contain the following code:

    Dim objLastASPError
    'Obtain an instance of the latest error
    Set objLastASPError = Server.GetLastError
    'Output some of the properties
    An error occurred:<BR>
    Description: <%=objLastASPError.Description%><BR>
    Category: <%=objLastASPError.Category%><BR>
    File: <%=objLastASPError.File%><BR>
    Number: <%=objLastASPError.Number%><BR>

    You can read the technical docs for a full listing of the ASPError object's properties.

    The ASPError object, along with the Server.Transfer and Server.Execute methods are the big additions to ASP 3.0. There are some minor changes. For example, in ASP 2.0, by default, Response.Buffer was set to False. In ASP 3.0, Response.Buffer is set to True. (Buffering output yields better performance.) Also, the ASP engine is more streamlined, and more efficient.

    That about wraps up the major changes. Of course, with ASP 3.0 comes the latest scripting engine versions for both VBScript and JScript. You can read about these at Microsoft's Scripting Site.

    Happy Programming!

  • Read Part 1

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article