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

ID: Q182036


The information in this article applies to:


SUMMARY

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

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 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.


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" %>
   <HTML>
   <HEAD>
   <TITLE>Simple Transactional Web Page</TITLE>
   </HEAD>
   <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">
   <p>
   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.
   </p>
   <p>
   Please wait until the script times out...
   </p>

   <%
     Do while 1 = 1
       'Infinite Loop
     Loop
   %>
   </BODY>
   </HTML>
   <%
    ' 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
   %> 


REFERENCES

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:

http://localhost/iishelp/iis/misc/default.asp
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:
http://support.microsoft.com/support/vinterdev/

Additional query words:


Keywords          : kbcode kbASP kbJScript kbScript kbVBScript kbVisID kbVisID100 kbVisID600 kbGrpASP VIServer VIScripting 
Version           : WINDOWS:1.0,6.0; winnt:2.0
Platform          : WINDOWS winnt 
Issue type        : kbhowto 

Last Reviewed: May 11, 1999