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 occurblack.
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=requiblack" argument in the @ Directives tag on the first line of the page.
<%@ 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 %>
Hi, there is an error :)
ReplyDelete<%@ TRANSACTION="Required" LANGUAGE="VBScript" %>
Bye and thx for the article, it's very interested
Thanks
ReplyDelete