This documentation is archived and is not being maintained.

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)

public int StatusCode { get; set; }
/** @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 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);
    }
}

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
Show: