HttpResponse.IsClientConnected 속성

정의

클라이언트가 아직 서버에 연결되어 있는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsClientConnected { bool get(); };
public bool IsClientConnected { get; }
member this.IsClientConnected : bool
Public ReadOnly Property IsClientConnected As Boolean

속성 값

Boolean

클라이언트가 현재 연결되어 있으면true 이고, 그러지 않으면 false입니다.

예제

다음 예제에서는 이 속성을 사용하여 IsClientConnected 페이지를 요청하는 클라이언트가 서버에 연결되어 있는지 확인합니다. true이면 IsClientConnected 코드에서 메서드를 Redirect 호출하고 클라이언트는 다른 페이지를 봅니다. false이면 IsClientConnected 코드가 메서드를 End 호출하고 모든 페이지 처리가 종료됩니다.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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);
        }
        else
        {
            // If the browser is not connected
            // stop all response processing.
            Response.End();
        }
    }

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    Private Sub Page_Load(sender As Object, e As EventArgs)

        ' Check whether the browser remains
        ' connected to the server.
        If (Response.IsClientConnected) Then

            ' If still connected, redirect
            ' to another page.             
            Response.Redirect("Page2VB.aspx", false)
        Else
            ' If the browser is not connected
            ' stop all response processing.
            Response.End()
        End If
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    </form>
</body>
</html>

설명

다음 IsClientConnected 조건이 true이면 속성이 반환 false 됩니다.

  • 클라이언트에 대한 연결이 종료되었습니다. 이 문제는 메서드가 Close 호출되었거나 클라이언트가 웹 페이지의 실행을 중지하거나 다른 페이지로 이동한 경우에 발생할 수 있습니다.

  • HttpWorkerRequest 요청을 처리하는 개체이거나 null 메서드가 HttpWorkerRequest.IsClientConnected 반환됩니다false. 사용자 지정 HttpWorkerRequest 개체가 요청을 HttpWorkerRequest.IsClientConnected 처리하는 경우 사용자 지정 조건에 따라 메서드가 설정될 수 있습니다. 예를 들어 사용자 지정 작업자 요청은 일정 시간 후에 강제로 제한 시간을 적용할 수 있습니다.

적용 대상