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.
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
' The Transacted Script Abort Handler. This sub-routine
' will be called if the script transacted aborts
Response.Write "<p><b>The Transaction just aborted</b>."
Response.Write "This message came from the "
Response.Write "OnTransactionAbort() event handler."
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:
Id. de artículo: 182036 - Última revisión: 08/14/2008 - Revisión: 1