<%@LANGUAGE="VBSCRIPT"%> Basic UltraDev
 


Is the Client Connected? Using the IsClientConnected Server Behavior

An ASP session will typically time out after 20 minutes by default, or whatever time limit that you set up for it with a Session.Timeout statement, as in the following:

<%
Session.Timeout=30
%>

However, in a busy site you may want to close the session if the user closes his or her browser to free up server memory. Luckily, there is a method of the Response object that can detect if a user is still connected: Response.IsClientConnected(). The Basic-UltraDev server behvavior can be used to automatically insert the necessary code to abandon a session if the user is no longer connected.

To apply the behavior, place your cursor within a repeat region or in an area where you want to test whether or not a user is connected, and choose IsClientConnected from the Basic-UltraDev menu. There are no parameters -- the code is simply inserted when you choose the server behavior.

The ideal place to insert this code is within a repeat region in a large recordset, or between recordsets or recordset displays on a page where there are more than one recordset. In IIS 4.0, the code had to be called after content has been sent to the browser.