[Serializable] |
The status of an HTTP request is contained in the HttpWebResponse.StatusCode property.
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com"); httpReq.AllowAutoRedirect = false; HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse(); if (httpRes.StatusCode==HttpStatusCode.Moved) { // Code for moved resources goes here. } // Close the response. httpRes.Close();
Accepted | Equivalent to HTTP status 202. HttpStatusCode.Accepted indicates that the request has been accepted for further processing. |
Ambiguous | Equivalent to HTTP status 300. HttpStatusCode.Ambiguous indicates that the requested information has multiple representations. The default action is to treat this status as a redirect and follow the contents of the Location header associated with this response. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.Ambiguous will cause an exception to be thrown. HttpStatusCode.Ambiguous is a synonym for HttpStatusCode.MultipleChoices. |
BadGateway | Equivalent to HTTP status 502. HttpStatusCode.BadGateway indicates that an intermediate proxy server received a bad response from another proxy or the origin server. |
BadRequest | Equivalent to HTTP status 400. HttpStatusCode.BadRequest indicates that the request could not be understood by the server. HttpStatusCode.BadRequest is sent when no other error is applicable, or if the exact error is unknown or does not have its own error code. |
Conflict | Equivalent to HTTP status 409. HttpStatusCode.Conflict indicates that the request could not be carried out due to a conflict on the server. |
Continue | Equivalent to HTTP status 100. HttpStatusCode.Continue indicates that the client may continue with its request. |
Created | Equivalent to HTTP status 201. HttpStatusCode.Created indicates that the request resulted in a new resource created before the response was sent. |
ExpectationFailed | Equivalent to HTTP status 417. HttpStatusCode.ExpectationFailed indicates that an expectation given in an Expect header could not be met by the server. |
Forbidden | Equivalent to HTTP status 403. HttpStatusCode.Forbidden indicates that the server refuses to fulfill the request. |
Found | Equivalent to HTTP status 302. HttpStatusCode.Found indicates that the requested information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will use the GET method. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.Found will cause an exception to be thrown. HttpStatusCode.Found is a synonym for HttpStatusCode.Redirect. |
GatewayTimeout | Equivalent to HTTP status 504. HttpStatusCode.GatewayTimeout indicates that an intermediate proxy server timed out while waiting for a response from another proxy or the origin server. |
Gone | Equivalent to HTTP status 410. HttpStatusCode.Gone indicates that the requested resource is not longer available. |
HttpVersionNotSupported | Equivalent to HTTP status 505. HttpStatusCode.HttpVersionNotSupported indicates that the requested HTTP version is not supported by the server. |
InternalServerError | Equivalent to HTTP status 500. HttpStatusCode.InternalServerError indicates that a generic error has occurred on the server. |
LengthRequired | Equivalent to HTTP status 411. HttpStatusCode.LengthRequired indicates that the required Content-length header is missing. |
MethodNotAllowed | Equivalent to HTTP status 405. HttpStatusCode.MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource. |
Moved | Equivalent to HTTP status 301. HttpStatusCode.Moved indicates that the requested information has been moved to the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will use the GET method. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.Moved will cause an exception to be thrown. HttpStatusCode.Moved is a synonym for HttpStatusCode.MovedPermanently. |
MovedPermanently | Equivalent to HTTP status 301. HttpStatusCode.MovedPermanently indicates that the requested information has been moved to the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.MovedPermanently will cause an exception to be thrown. HttpStatusCode.MovedPermanently is a synonym for HttpStatusCode.Moved. |
MultipleChoices | Equivalent to HTTP status 300. HttpStatusCode.MultipleChoices indicates that the requested information has multiple representations. The default action is to treat this status as a redirect and follow the contents of the Location header associated with this response. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.MultipleChoices will cause an exception to be thrown. HttpStatusCode.MultipleChoices is a synonym for HttpStatusCode.Ambiguous. |
NoContent | Equivalent to HTTP status 204. HttpStatusCode.NoContent indicates that the request has been successfully processed and that the response is intentionally blank. |
NonAuthoritativeInformation | Equivalent to HTTP status 203. HttpStatusCode.NonAuthoritativeInformation indicates that the returned metainformation is from a cached copy instead of the origin server and therefore may be incorrect. |
NotAcceptable | Equivalent to HTTP status 406. HttpStatusCode.NotAcceptable indicates that the client has indicated with Accept headers that it will not accept any of the available representations of the resource. |
NotFound | Equivalent to HTTP status 404. HttpStatusCode.NotFound indicates that the requested resource does not exist on the server. |
NotImplemented | Equivalent to HTTP status 501. HttpStatusCode.NotImplemented indicates the server does not support the requested function. |
NotModified | Equivalent to HTTP status 304. HttpStatusCode.NotModified indicates that the client's cached copy is up to date. The contents of the resource is not transferred. |
OK | Equivalent to HTTP status 200. HttpStatusCode.OK indicates that the request succeeded and the requested information is in the response. This is the most common status code to receive. |
PartialContent | Equivalent to HTTP status 206. HttpStatusCode.PartialContent indicates that the response is a partial response as requested by a GET request that includes a byte range. |
PaymentRequired | Equivalent to HTTP status 402. HttpStatusCode.PaymentRequired is reserved for future use. |
PreconditionFailed | Equivalent to HTTP status 412. HttpStatusCode.PreconditionFailed indicates that a condition set for this request failed, and the request cannot be carried out. Conditions are set with conditional request headers such as If-Match, If-None-Match, or If-Unmodified-Since. |
ProxyAuthenticationRequired | Equivalent to HTTP status 407. HttpStatusCode.ProxyAuthenticationRequired indicates that the requested proxy requires authentication. The Proxy-authenticate header contains the details of how to perform the authentication. |
Redirect | Equivalent to HTTP status 302. HttpStatusCode.Redirect indicates that the requested information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will use the GET method. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.Redirect will cause an exception to be thrown. HttpStatusCode.Redirect is a synonym for HttpStatusCode.Found. |
RedirectKeepVerb | Equivalent to HTTP status 307. HttpStatusCode.RedirectKeepVerb indicates that the request information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will also use the POST method. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.RedirectKeepVerb will cause an exception to be thrown. HttpStatusCode.RedirectKeepVerb is a synonym for HttpStatusCode.TemporaryRedirect. |
RedirectMethod | Equivalent to HTTP status 303. HttpStatusCode.RedirectMethod automatically redirects the client to the URI specified in the Location header as the result of a POST. The request to the resource specified by the Location header will be made with a GET. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.RedirectMethod will cause an exception to be thrown. HttpStatusCode.RedirectMethod is a synonym for HttpStatusCode.SeeOther. |
RequestedRangeNotSatisfiable | Equivalent to HTTP status 416. HttpStatusCode.RequestedRangeNotSatisfiable indicates that the range of data requested from the resource cannot be returned, either because the beginning of the range is before the beginning of the resource, or the end of the range is after the end of the resource. |
RequestEntityTooLarge | Equivalent to HTTP status 413. HttpStatusCode.RequestEntityTooLarge indicates that the request is too large for the server to process. |
RequestTimeout | Equivalent to HTTP status 408. HttpStatusCode.RequestTimeout indicates that the client did not send a request within the time the server was expecting the request. |
RequestUriTooLong | Equivalent to HTTP status 414. HttpStatusCode.RequestUriTooLong indicates that the URI is too long. |
ResetContent | Equivalent to HTTP status 205. HttpStatusCode.ResetContent indicates that the client should reset (not reload) the current resource. |
SeeOther | Equivalent to HTTP status 303. HttpStatusCode.SeeOther automatically redirects the client to the URI specified in the Location header as the result of a POST. The request to the resource specified by the Location header will be made with a GET. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.SeeOther will cause an exception to be thrown. HttpStatusCode.SeeOther is a synonym for HttpStatusCode.RedirectMethod. |
ServiceUnavailable | Equivalent to HTTP status 503. HttpStatusCode.ServiceUnavailable indicates that the server is temporarily unavailable, usually due to high load or maintenance. |
SwitchingProtocols | Equivalent to HTTP status 101. HttpStatusCode.SwitchingProtocols indicates that the protocol version or protocol is being changed. |
TemporaryRedirect | Equivalent to HTTP status 307. HttpStatusCode.TemporaryRedirect indicates that the request information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will also use the POST method. If the HttpWebRequest.AllowAutoRedirect property is false, HttpStatusCode.TemporaryRedirect will cause an exception to be thrown. HttpStatusCode.TemporaryRedirect is a synonym for HttpStatusCode.RedirectKeepVerb. |
Unauthorized | Equivalent to HTTP status 401. HttpStatusCode.Unauthorized indicates that the requested resource requires authentication. The WWW-Authenticate header contains the details of how to perform the authentication. |
UnsupportedMediaType | Equivalent to HTTP status 415. HttpStatusCode.UnsupportedMediaType indicates that the request is an unsupported type. |
Unused | Equivalent to HTTP status 306. HttpStatusCode.Unused is a proposed extension to the HTTP/1.1 specification that is not fully specified. |
UseProxy | Equivalent to HTTP status 305. HttpStatusCode.UseProxy indicates that the request should use the proxy server at the URI specified in the Location header. |
Hierarchy: