HttpStatusCode HttpStatusCode HttpStatusCode HttpStatusCode Enum

Definition

Contains the values of status codes defined for HTTP.

public enum class HttpStatusCode
public enum HttpStatusCode
type HttpStatusCode = 
Public Enum HttpStatusCode
Inheritance
HttpStatusCodeHttpStatusCodeHttpStatusCodeHttpStatusCode

Fields

Accepted Accepted Accepted Accepted 202

Equivalent to HTTP status 202. Accepted indicates that the request has been accepted for further processing.

AlreadyReported AlreadyReported AlreadyReported AlreadyReported 208
Ambiguous Ambiguous Ambiguous Ambiguous 300

Equivalent to HTTP status 300. 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.

BadGateway BadGateway BadGateway BadGateway 502

Equivalent to HTTP status 502. BadGateway indicates that an intermediate proxy server received a bad response from another proxy or the origin server.

BadRequest BadRequest BadRequest BadRequest 400

Equivalent to HTTP status 400. BadRequest indicates that the request could not be understood by the server. 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 Conflict Conflict Conflict 409

Equivalent to HTTP status 409. Conflict indicates that the request could not be carried out because of a conflict on the server.

Continue Continue Continue Continue 100

Equivalent to HTTP status 100. Continue indicates that the client can continue with its request.

Created Created Created Created 201

Equivalent to HTTP status 201. Created indicates that the request resulted in a new resource created before the response was sent.

EarlyHints EarlyHints EarlyHints EarlyHints 103
ExpectationFailed ExpectationFailed ExpectationFailed ExpectationFailed 417

Equivalent to HTTP status 417. ExpectationFailed indicates that an expectation given in an Expect header could not be met by the server.

FailedDependency FailedDependency FailedDependency FailedDependency 424
Forbidden Forbidden Forbidden Forbidden 403

Equivalent to HTTP status 403. Forbidden indicates that the server refuses to fulfill the request.

Found Found Found Found 302

Equivalent to HTTP status 302. 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.

GatewayTimeout GatewayTimeout GatewayTimeout GatewayTimeout 504

Equivalent to HTTP status 504. GatewayTimeout indicates that an intermediate proxy server timed out while waiting for a response from another proxy or the origin server.

Gone Gone Gone Gone 410

Equivalent to HTTP status 410. Gone indicates that the requested resource is no longer available.

HttpVersionNotSupported HttpVersionNotSupported HttpVersionNotSupported HttpVersionNotSupported 505

Equivalent to HTTP status 505. HttpVersionNotSupported indicates that the requested HTTP version is not supported by the server.

IMUsed IMUsed IMUsed IMUsed 226
InsufficientStorage InsufficientStorage InsufficientStorage InsufficientStorage 507
InternalServerError InternalServerError InternalServerError InternalServerError 500

Equivalent to HTTP status 500. InternalServerError indicates that a generic error has occurred on the server.

LengthRequired LengthRequired LengthRequired LengthRequired 411

Equivalent to HTTP status 411. LengthRequired indicates that the required Content-length header is missing.

Locked Locked Locked Locked 423
LoopDetected LoopDetected LoopDetected LoopDetected 508
MethodNotAllowed MethodNotAllowed MethodNotAllowed MethodNotAllowed 405

Equivalent to HTTP status 405. MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource.

MisdirectedRequest MisdirectedRequest MisdirectedRequest MisdirectedRequest 421
Moved Moved Moved Moved 301

Equivalent to HTTP status 301. 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.

MovedPermanently MovedPermanently MovedPermanently MovedPermanently 301

Equivalent to HTTP status 301. 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.

MultipleChoices MultipleChoices MultipleChoices MultipleChoices 300

Equivalent to HTTP status 300. 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.

MultiStatus MultiStatus MultiStatus MultiStatus 207
NetworkAuthenticationRequired NetworkAuthenticationRequired NetworkAuthenticationRequired NetworkAuthenticationRequired 511
NoContent NoContent NoContent NoContent 204

Equivalent to HTTP status 204. NoContent indicates that the request has been successfully processed and that the response is intentionally blank.

NonAuthoritativeInformation NonAuthoritativeInformation NonAuthoritativeInformation NonAuthoritativeInformation 203

Equivalent to HTTP status 203. NonAuthoritativeInformation indicates that the returned metainformation is from a cached copy instead of the origin server and therefore may be incorrect.

NotAcceptable NotAcceptable NotAcceptable NotAcceptable 406

Equivalent to HTTP status 406. NotAcceptable indicates that the client has indicated with Accept headers that it will not accept any of the available representations of the resource.

NotExtended NotExtended NotExtended NotExtended 510
NotFound NotFound NotFound NotFound 404

Equivalent to HTTP status 404. NotFound indicates that the requested resource does not exist on the server.

NotImplemented NotImplemented NotImplemented NotImplemented 501

Equivalent to HTTP status 501. NotImplemented indicates that the server does not support the requested function.

NotModified NotModified NotModified NotModified 304

Equivalent to HTTP status 304. NotModified indicates that the client's cached copy is up to date. The contents of the resource are not transferred.

OK OK OK OK 200

Equivalent to HTTP status 200. OK indicates that the request succeeded and that the requested information is in the response. This is the most common status code to receive.

PartialContent PartialContent PartialContent PartialContent 206

Equivalent to HTTP status 206. PartialContent indicates that the response is a partial response as requested by a GET request that includes a byte range.

PaymentRequired PaymentRequired PaymentRequired PaymentRequired 402

Equivalent to HTTP status 402. PaymentRequired is reserved for future use.

PermanentRedirect PermanentRedirect PermanentRedirect PermanentRedirect 308
PreconditionFailed PreconditionFailed PreconditionFailed PreconditionFailed 412

Equivalent to HTTP status 412. PreconditionFailed indicates that a condition set for this request failed, and the request cannot be carried out. Conditions are set with conditional request headers like If-Match, If-None-Match, or If-Unmodified-Since.

PreconditionRequired PreconditionRequired PreconditionRequired PreconditionRequired 428
Processing Processing Processing Processing 102
ProxyAuthenticationRequired ProxyAuthenticationRequired ProxyAuthenticationRequired ProxyAuthenticationRequired 407

Equivalent to HTTP status 407. ProxyAuthenticationRequired indicates that the requested proxy requires authentication. The Proxy-authenticate header contains the details of how to perform the authentication.

Redirect Redirect Redirect Redirect 302

Equivalent to HTTP status 302. 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.

RedirectKeepVerb RedirectKeepVerb RedirectKeepVerb RedirectKeepVerb 307

Equivalent to HTTP status 307. 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.

RedirectMethod RedirectMethod RedirectMethod RedirectMethod 303

Equivalent to HTTP status 303. 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.

RequestedRangeNotSatisfiable RequestedRangeNotSatisfiable RequestedRangeNotSatisfiable RequestedRangeNotSatisfiable 416

Equivalent to HTTP status 416. 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 RequestEntityTooLarge RequestEntityTooLarge RequestEntityTooLarge 413

Equivalent to HTTP status 413. RequestEntityTooLarge indicates that the request is too large for the server to process.

RequestHeaderFieldsTooLarge RequestHeaderFieldsTooLarge RequestHeaderFieldsTooLarge RequestHeaderFieldsTooLarge 431
RequestTimeout RequestTimeout RequestTimeout RequestTimeout 408

Equivalent to HTTP status 408. RequestTimeout indicates that the client did not send a request within the time the server was expecting the request.

RequestUriTooLong RequestUriTooLong RequestUriTooLong RequestUriTooLong 414

Equivalent to HTTP status 414. RequestUriTooLong indicates that the URI is too long.

ResetContent ResetContent ResetContent ResetContent 205

Equivalent to HTTP status 205. ResetContent indicates that the client should reset (not reload) the current resource.

SeeOther SeeOther SeeOther SeeOther 303

Equivalent to HTTP status 303. 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.

ServiceUnavailable ServiceUnavailable ServiceUnavailable ServiceUnavailable 503

Equivalent to HTTP status 503. ServiceUnavailable indicates that the server is temporarily unavailable, usually due to high load or maintenance.

SwitchingProtocols SwitchingProtocols SwitchingProtocols SwitchingProtocols 101

Equivalent to HTTP status 101. SwitchingProtocols indicates that the protocol version or protocol is being changed.

TemporaryRedirect TemporaryRedirect TemporaryRedirect TemporaryRedirect 307

Equivalent to HTTP status 307. 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.

TooManyRequests TooManyRequests TooManyRequests TooManyRequests 429
Unauthorized Unauthorized Unauthorized Unauthorized 401

Equivalent to HTTP status 401. Unauthorized indicates that the requested resource requires authentication. The WWW-Authenticate header contains the details of how to perform the authentication.

UnavailableForLegalReasons UnavailableForLegalReasons UnavailableForLegalReasons UnavailableForLegalReasons 451
UnprocessableEntity UnprocessableEntity UnprocessableEntity UnprocessableEntity 422
UnsupportedMediaType UnsupportedMediaType UnsupportedMediaType UnsupportedMediaType 415

Equivalent to HTTP status 415. UnsupportedMediaType indicates that the request is an unsupported type.

Unused Unused Unused Unused 306

Equivalent to HTTP status 306. Unused is a proposed extension to the HTTP/1.1 specification that is not fully specified.

UpgradeRequired UpgradeRequired UpgradeRequired UpgradeRequired 426

Equivalent to HTTP status 426. UpgradeRequired indicates that the client should switch to a different protocol such as TLS/1.0.

UseProxy UseProxy UseProxy UseProxy 305

Equivalent to HTTP status 305. UseProxy indicates that the request should use the proxy server at the URI specified in the Location header.

VariantAlsoNegotiates VariantAlsoNegotiates VariantAlsoNegotiates VariantAlsoNegotiates 506

Examples

The following example compares the status returned by an HttpWebResponse with a member of the HttpStatusCode class to determine the status of a response.

HttpWebRequest^ httpReq = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://www.contoso.com" ));
httpReq->AllowAutoRedirect = false;
HttpWebResponse^ httpRes = dynamic_cast<HttpWebResponse^>(httpReq->GetResponse());
if ( httpRes->StatusCode == HttpStatusCode::Moved )
{
   // Code for moved resources goes here.
}

// Close the response.
httpRes->Close();
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();
Dim httpReq As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest)
httpReq.AllowAutoRedirect = False
       
Dim httpRes As HttpWebResponse = CType(httpReq.GetResponse(), HttpWebResponse)
       
If httpRes.StatusCode = HttpStatusCode.Moved Then
    ' Code for moved resources goes here.
End If

httpRes.Close()

Remarks

The HttpStatusCode enumeration contains the values of the status codes defined in RFC 2616 for HTTP 1.1.

The status of an HTTP request is contained in the HttpWebResponse.StatusCode property.

Applies to