Name
IsClientConnected —
Response.IsClientConnected
Synopsis
A read-only property that evaluates to True if the
client is still connected to the web server since the last use of the
Response object's Write method and returns
False otherwise.
Parameters
None
Example
<% ' The following code determines whether the client ' is still connected to the server. If it is still ' connected, then the SessionID (see Chapter 10) will be ' used to retrieve the user information from a database. If Response.IsClientConnected Then strUserName = fn_strGetUserName(Session.SessionId) End If %>
Notes
The IsClientConnected property gives you the ability to determine whether the client has disconnected. This is very important if the current script is long. If the client is no longer connected, it may be important to discontinue processing a script.
The following example demonstrates checking for the client connection before continuing in a long script. If the client is no longer connected, the easiest way to stop all processing is to use the Response object's End method.
<%Response.Buffer = True%> <HTML> <HEAD><TITLE>One Long Script</TITLE></HEAD> <BODY> <% ' The following code is the first of two segments ' in this script that will take a long time to process: [SOME LONG CODE] ' Now before performing the second half of this long script, ' check to see if the client is still connected. If Response.IsClientConnected Then [SECOND LONG CODE SEGMENT] Else ' The client is no longer connected, end the script's ' ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access