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


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" %>
<TITLE>Simple Transactional Web Page</TITLE>
<BODY BGCOLOR="White" topmargin="10" leftmargin="10">
<font size="4" face="Arial, Helvetica">
<b>Transactional Web Page</b></font><br>
<hr size="1" color="#000000">
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
' The Transacted Script Abort Handler. This sub-routine
' will be called if the script transacted aborts

Sub OnTransactionAbort()
Response.Write "<p><b>The Transaction just aborted</b>."
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


Additional samples of ASP functionality can be found in the Windows NT Option Pack Documentation. This documentation is installed by default and can be accessed from your Web server at the following location:

For the latest Knowledge Base articles and other support information on Visual InterDev and Active Server Pages, see the following page on the Microsoft Technical Support site:


Id. de artículo: 182036 - Última revisión: 08/14/2008 - Revisión: 1