The Barnes & Noble Review
If you're an experienced developer working with ASP 3 and IIS 5.0, here's the authoritative, real-world ASP reference you'll use every day. Building on his best-selling first edition, A. Keyton Weissinger offers detailed insight for making the most of ASP 3 and the IIS object model, followed by a comprehensive reference focusing on real-world applications and illuminating underpublicized ASP features that offer you powerful opportunities.
ASP in a Nutshell, Second Edition presents detailed coverage of every key ASP object: when you'd use it, how it works, its properties, collections, methods, events, any accessory files or DLLs you'll need, and (in many cases) tricks from the author's personal grab-bag. Weissinger introduces preprocessing directives, server-side includes, GLOBAL.ASA, and much more. You'll also learn how to use the powerful components that ship with ASP 3.0 and IIS 5.0, including its ADO 2.6 support and prebuilt components for ad and content rotation, browsing, CDO-based workflow and messaging, content linking, page counters, file access, logging, permission checking, and more.
Four valuable appendices cover ASP Intrinsic Objects, conversion of CGI/WinCGI applications to ASP, ASP on alternative platforms (e.g., ChiliSoft); and configuring ASP applications on IIS.
Bill Camarda, bn.com editor
ASP (active server pages) technology is a model of dynamic information service, which means the user gets customized information rather than static, designed-for-everyone html pages. ASP also has an open-source initiative, which gives legs to ASP outside of Microsoft; presently it runs on everything from Microsoft to Unix/Linux, Mac, and SGI. This manual is not for beginners, but this is a highly lucrative area at the moment. Copyright 1999 Cahners Business Information.
This reference guide for developers shows how particular object model features are used in a real application, and highlights little- known or undocumented aspects. The second edition is updated to cover ASP 3.0 and IIS 5.0. Annotation c. Book News, Inc., Portland, OR (booknews.com)
Read an Excerpt
Chapter 6: ObjectContext ObjectAs of version 2.0, an important feature of Active Server Pages is the ability to create a transactional script: one whose constituent code segments all succeed completely or fail as a group. For example, using such a script, one section of code could remove a record from an inventory table, and a second section could add a record to a sales log table. However, only if both sections of code succeed does the script itself succeed. If the removal of the inventory record or the addition of the sales record fails, the script itself fails. Both processes are rolled back: the deleted record, if it was removed, is added back into the database, and the sales record, if it was added, is removed from the sales log table. This ability to wrap several functions in a single transactional unit that succeeds or fails as a whole is an important improvement in the power of ASP applications. Previously, all transactions relied on database transaction support.
ASP application transactions are controlled by Windows 2000 COM+ Component Services or Windows NT's Microsoft Transaction Server (MTS). This piece of the BackOffice suite allows control over all database actions coded to use it. Support for transactional scripts is built into IIS and Personal Web Server and does not require any special setup. Without COM+ Component Services' or, in ASP 2.0, MTS transactional support, your applications would have to track all database changes manually and roll back all database actions by hand, keeping track of multiuser and concurrency issues, etc. MTS or COM+ Component Services gives this support for very little extra coding--as long as the database your application is connected to supports the XA protocol from the X/Open consortium. Note that this support is currently limited to SQL Server. Note, also, that this means that file actions are not yet supported--or at least, not automatically.
ASP's support of transactions is coded through the use of the ObjectContext object, which represents the actual ObjectContext object of COM+ Component Services itself. By calling methods of the ObjectContext object and coding its events, you can create a transactional script with only a few more lines of code.
To declare all the script on a given page to be transactional, simply add the following line of code as the first line in your script:
<%@ TRANSACTION = Required %>
For more details on the
TRANSACTION ASP directive, see Chapter 11, Preprocessing Directives, Server-Side Includes, and GLOBAL.ASA. Here it is important only that this line be the first in your script; including this line alerts the web server to use Component Services to ensure that the script succeeds or fails as a whole.
To commit the transaction or abort it, you simply call the SetComplete or SetAbort methods of the ObjectContext object, respectively. If you are dealing with a complex transaction containing segments of code that are not supported by Component Services (notably file actions), you can specially code for these actions in the ObjectContext events OnTransactionCommit and OnTransactionAbort. There are examples of all of these methods and event procedures in the reference section later in this chapter.
There are currently two very important limitations in constructing transactional scripts:
- Only database actions are supported, and only databases that support the XA protocol are supported by COM+ Component Services or MTS.
- A transaction cannot span more than one ASP page. For this reason, you must be very careful in creating your pages: they must include all the actions required by your transactions but not be so large as to slow the processing of the page by too large a percentage...