HttpResponse.StatusCode Property

Gets or sets the HTTP status code of the output returned to the client.

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

'Declaration
Public Property StatusCode As Integer
'Usage
Dim instance As HttpResponse
Dim value As Integer

value = instance.StatusCode

instance.StatusCode = value
/** @property */
public int get_StatusCode ()

/** @property */
public void set_StatusCode (int value)

public function get StatusCode () : int

public function set StatusCode (value : int)

Not applicable.

Property Value

An Integer representing the status of the HTTP output returned to the client. The default value is 200 (OK).

Exception typeCondition

HttpException

StatusCode is set after the HTTP headers have been sent.

The following code example checks the status code of the output stream. If the status code is not equal to 200, additional code is executed.


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

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: