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.

[Visual Basic]
Public Property StatusCode As Integer
[C#]
public int StatusCode {get; set;}
[C++]
public: __property int get_StatusCode();
public: __property void set_StatusCode(int);
[JScript]
public function get StatusCode() : int;
public function set StatusCode(int);

Property Value

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

Exceptions

Exception Type Condition
HttpException StatusCode is set after the HTTP headers have been sent.

Example

The following example takes action if the status code is not 200.

[Visual Basic] 
If Response.StatusCode <> 200 Then
    '...
 End If
    

[C#] 
if (Response.StatusCode != 200) 
 {
   // ...
 }
    

[C++] 
if (Response->StatusCode != 200) 
 {
   // ...
 }
    

[JScript] 
if(Response.StatusCode != 200){
  //...
}

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpResponse Class | HttpResponse Members | System.Web Namespace

Show: