Microsoft KB Archive/182036

= HOWTO: Use MTS to Trap Error 'ASP 0113' Script Timed Out =

Article ID: 182036

Article Last Modified on 5/2/2006

-

APPLIES TO


 * Microsoft Visual InterDev 1.0 Standard Edition
 * Microsoft Visual InterDev 6.0 Standard Edition
 * Microsoft Active Server Pages 4.0
 * Microsoft Transaction Services 2.0
 * Microsoft Internet Information Server 4.0
 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q182036



SUMMARY
In a production environment, it is common to trap any errors that occur in your Active Server Pages (ASP) page by using the statement "On Error Resume Next." However, if a script time-out error occurs, it is not possible to trap that error by using this method because the ScriptTimeout is happening separately from the ASP error collection.

If, however, you make the ASP page transactional, you will be able to, in essence, handle the error. When the script time-out occurs, the transaction will have failed, and if you made any changes to a resource that supports transactions, such as Microsoft SQL Server, the changes will be rolled back. In addition, your ASP page can contain a procedure named OnTransactionAbort that will execute when the transaction fails, even if the failure was due to a time-out or other error in that ASP page. The client will still receive the ASP 0113, but by using OnTransactionAbort, you have the ability to so something after the ScriptTimeout has occurred.



MORE INFORMATION
Transactional ASP pages must be hosted on Internet Information Server 4.0 or higher. To make an ASP page transactional, the page must contain the "TRANSACTION=required" argument in the @ Directives tag on the first line of the page.

The following code sample demonstrates trapping the script time-out error: <%@ TRANSACTION=Required LANGUAGE="VBScript" %>   Simple Transactional Web Page    Transactional Web Page  This is an example of an Aborted Transaction. This transaction will abort due to a Script Time-out error, which is an error that you could not trap without a transaction. Please wait until the script times out...

<%    Do while 1 = 1 'Infinite Loop Loop %>    <%   ' The Transacted Script Abort Handler. This sub-routine ' will be called if the script transacted aborts

Sub OnTransactionAbort Response.Write " The Transaction just aborted." Response.Write "This message came from the " Response.Write "OnTransactionAbort event handler." end sub %> NOTE: This script will run until one of two events occurs. Either Server.ScriptTimeout is reached and an ASP 0113 is returned, or because the page is enlisting in a transaction, it is being affected by the default transaction timeout of 60 seconds.

You can determine which event occurred in the IIS log files. If the script times out as a result of exceeding Server.ScriptTimeout, an "ASP 0113" will be reported to the client and logged in the Web logs.

If the page is terminated because of a transaction timeout, an "HTTP 200" will be recorded in the Web log, indicating a success. Only by checking OnTransactionAbort will you see this failure.

Also in MTS as part of Windows NT 4.0, transaction timeout is only configurable on a per-server level. This has been changed in COM+ (Windows 2000) so that transaction timeouts can be configured on a component level. For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

287499 HOWTO: Change the Transaction Timeout Value for MTS or COM+

253669 INFO: What's New with COM+ 1.0

