IsClientConnected Property

HttpResponse.IsClientConnected Property


Gets a value indicating whether the client is still connected to the server.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public bool IsClientConnected { get; }

Property Value

Type: System.Boolean

true if the client is currently connected; otherwise, false.

The IsClientConnected property returns false when the following conditions are true:

The following example uses the IsClientConnected property to check whether the client that is requesting the page remains connected to the server. If IsClientConnected is true, the code calls the Redirect method, and the client will view another page. If IsClientConnected is false, then the code calls the End method and all page processing is terminated.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">

    private void Page_Load(object sender, EventArgs e)
        // Check whether the browser remains
        // connected to the server.
        if (Response.IsClientConnected)
            // If still connected, redirect
            // to another page. 
            Response.Redirect("Page2CS.aspx", false);
            // If the browser is not connected
            // stop all response processing.

<html xmlns="" >
    <title>ASP.NET Example</title>
    <form id="form1" runat="server">

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft