HttpResponse.StatusCode 속성

정의

클라이언트에 반환된 출력의 HTTP 상태 코드를 가져오거나 설정합니다.

public:
 property int StatusCode { int get(); void set(int value); };
public int StatusCode { get; set; }
member this.StatusCode : int with get, set
Public Property StatusCode As Integer

속성 값

클라이언트에 반환된 HTTP 출력의 상태를 나타내는 정수입니다. 기본값은 200(OK)입니다. 유효한 상태 코드 목록은 HTTP 상태 코드를 참조하세요.

예외

StatusCode 는 HTTP 헤더를 보낸 후에 설정됩니다.

예제

다음 예제에서는 출력 스트림의 상태 코드를 확인합니다. 상태 코드가 200과 같지 않으면 추가 코드가 실행됩니다.

protected void Page_Load(object sender, EventArgs e)
{
    // Show success or failure of page load.
    if (Response.StatusCode != 200)
    {
        Response.Write("There was a problem accessing the web resource" +
            "<br />" + Response.StatusDescription);
    }
}

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Show success or failure of page load.
    If Response.StatusCode <> 200 Then
        Response.Write("There was a problem accessing the web resource." & _
            "<br />" & Response.StatusDescription)
    End If

End Sub

적용 대상

추가 정보