Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Loops: DO WHILE/UNTIL #1
     [next Lesson]  Loops: Intercepting Timeouts #3

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

<Test Script Below>


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

<Test Script Below>


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

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.