|
Do Loop and Timeouts by
Charles Carroll
A loop that is infinite will not run forever. IIS will timeout the script
(default is 90 seconds).
Here is an infinite loop that IIS will timeout:
filename=/learn/test/loop1.asp
<%response.buffer=true%>
<TITLE>doloop1.asp</TITLE>
<body bgcolor="#FFFFFF">
<HTML>
<%
' the below code is an infinite loop. I commented it out to avoid filling my server RAM.
' DO
' counter=counter+1
' response.write counter & "<br>"
' response.flush
' LOOP
%>
</BODY>
</HTML>
Here is an infinite loop that we explicitly set a timeout for:
filename=/learn/test/loop2.asp
<%
response.buffer=true
server.scripttimeout=10
%>
<TITLE>loop2.asp</TITLE>
<body bgcolor="#FFFFFF">
<HTML>
<head><meta name="Robots" content="Noindex,Nofollow" /></head>
<%
DO UNTIL COUNTER = 111111
counter=counter+1
iFlush = iflush + 1
if iflush = 25 then
iflush = 0
Response.Flush
end if
response.write counter & "<br>"
LOOP
%>
</BODY>
</HTML>
It has been assumed that a timed out script was impossible to intercept, but
the next lesson shows how to use the transactional aspect of an ASP script to
capture this elusive condition.
|