Name
IsClientConnected
Synopsis
Boolean = Response.IsClientConnected
Returns
a Boolean indicating whether the
client is still connected. Returns False if the
client is no longer connected.
Parameters
-
Boolean A Boolean variable to receive the value of the property.
Example
The example checks the IsClientConnected property before starting a
long-running processing task in order to avoid the expense of running
the task if the client is no longer connected. If the property
returns False, the code calls the Response.End
method. Even though the client has disconnected and can no longer
receive the buffered output (which is sent when the End method is
called), calling the End method is still a good idea, since it will
halt further processing of the page and fire the
Application_EndRequest event. If you have written cleanup code for
the page that is run by the event handler for Application_EndRequest,
calling Response.End will ensure that the cleanup code is executed,
even if the client disconnects.
Sub Page_Load( )
'Check client connection status
If Response.IsClientConnected = False Then
Response.End
Else
'Start long-running processing task
End If
End SubNotes
The IsClientConnected property is especially useful for long-running processes that require a significant amount of processing resources on the server. By querying the IsClientConnected property before starting an expensive processing task, or by querying the property periodically during processing, you can bypass further processing ...
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