PROPERTY:  Response.IsClientConnected

Modified in version 3.0

The IsClientConnected property determines if the client has disconnected from the server since the last Response.Write. This property is particularly useful since it will prevent the server from continuing to attempt to pass information after an unexpected disconnect.

In ASP 2.0, you must first attempt to pass information to the client in order to use this property. However, in ASP 3.0 you can check the response of using this property before passing any content to the client. (Thus, a simple test will prevent the server from performing unneccesary work.)

In the example code, the output will be a list of all the book titles that are in the database. However, if the user stops the connection to the server, then the only a partial list of titles will be created.

Code:
<%
set connDB=server.createobject("adodb.connection")
connDB.Open "books", "", ""
mySQL="select * from books"
Set rsBookSrch = Server.CreateObject("ADODB.Recordset")
rsBookSrch.Open mySQL, connDB, adOpenStatic, adLockPessimistic
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Do until (rsBookSrch.eof or Response.IsClientConnected=false)
Response.Write rsBookSrch.Fields("Title") %> <br>
<% rsBookSrch.MoveNext
Loop
rsBookSrch.Close
connDB.Close
%>
</BODY>
</HTML>
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information