StatusCode Property

HttpWebResponse.StatusCode Property


Gets the status of the response.

Namespace:   System.Net
Assembly:  System (in System.dll)

public virtual HttpStatusCode StatusCode { get; }

Property Value

Type: System.Net.HttpStatusCode

One of the HttpStatusCode values.

Exception Condition

The current instance has been disposed.

The StatusCode parameter is a number that indicates the status of the HTTP response. The expected values for status are defined in the HttpStatusCode class.

The following example uses StatusCode to verify that the status of the HttpWebResponse is OK.

Snippet section 1 of code snippet {"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"8ef51349-966d-42c5-bd57-64ef9e3e9684","entity_type":"CodeSnippet","locale":"en-US"} in source file ({"filename":"/CS/httpwebresponse_statuscode_statusdescription.cs","blob_type":"Source","blob_id":"-002fcs-002fhttpwebresponse-005fstatuscode-005fstatusdescription-002ecs","blob_revision":2}) overlaps with other snippet sections. Ensure the tags are placed correctly.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft