public enum HttpStatusCode
Object
ValueType
Enum
HttpStatusCode
System
Networking
Contains the values of status codes defined for the Hypertext Transfer Protocol (HTTP).
This enumeration is used by HttpWebResponse.[Note: The HttpStatusCode enumeration contains the values of the status codes defined in IETF RFC 2616 - HTTP/1.1.
The status of an HTTP request is contained in the System.Net.HttpWebResponse.StatusCode property.
]
The following example compares the status returned by a HttpWebResponse with a HttpStatusCode value to determine the status of the response.
using System; using System.Net; public class HttpStatusCodeExample { public static void Main() { string serverName = "http://www.contoso.com"; HttpWebRequest httpReq = (HttpWebRequest) WebRequest.Create(serverName); httpReq.AllowAutoRedirect = false; HttpWebResponse httpRes = (HttpWebResponse) httpReq.GetResponse(); if (httpRes.StatusCode==HttpStatusCode.Found) { Console.WriteLine("Request for {0} was redirected.", serverName); } } }The output is
Request for http://www.contoso.com was redirected.
System.Net Namespace
HttpStatusCode Fields
HttpStatusCode.Accepted Field
HttpStatusCode.Ambiguous Field
HttpStatusCode.BadGateway Field
HttpStatusCode.BadRequest Field
HttpStatusCode.Conflict Field
HttpStatusCode.Continue Field
HttpStatusCode.Created Field
HttpStatusCode.ExpectationFailed Field
HttpStatusCode.Forbidden Field
HttpStatusCode.Found Field
HttpStatusCode.GatewayTimeout Field
HttpStatusCode.Gone Field
HttpStatusCode.HttpVersionNotSupported Field
HttpStatusCode.InternalServerError Field
HttpStatusCode.LengthRequired Field
HttpStatusCode.MethodNotAllowed Field
HttpStatusCode.Moved Field
HttpStatusCode.MovedPermanently Field
HttpStatusCode.MultipleChoices Field
HttpStatusCode.NoContent Field
HttpStatusCode.NonAuthoritativeInformation Field
HttpStatusCode.NotAcceptable Field
HttpStatusCode.NotFound Field
HttpStatusCode.NotImplemented Field
HttpStatusCode.NotModified Field
HttpStatusCode.OK Field
HttpStatusCode.PartialContent Field
HttpStatusCode.PaymentRequired Field
HttpStatusCode.PreconditionFailed Field
HttpStatusCode.ProxyAuthenticationRequired Field
HttpStatusCode.Redirect Field
HttpStatusCode.RedirectKeepVerb Field
HttpStatusCode.RedirectMethod Field
HttpStatusCode.RequestEntityTooLarge Field
HttpStatusCode.RequestTimeout Field
HttpStatusCode.RequestUriTooLong Field
HttpStatusCode.RequestedRangeNotSatisfiable Field
HttpStatusCode.ResetContent Field
HttpStatusCode.SeeOther Field
HttpStatusCode.ServiceUnavailable Field
HttpStatusCode.SwitchingProtocols Field
HttpStatusCode.TemporaryRedirect Field
HttpStatusCode.Unauthorized Field
HttpStatusCode.UnsupportedMediaType Field
HttpStatusCode.Unused Field
HttpStatusCode.UseProxy Field
HttpStatusCode.value__ Field
Accepted = 202;
Equivalent to HTTP status 202. Indicates that the request has been accepted but not yet processed.[Note: For a detailed description of the HTTP status code 202, see Section 10.2.3 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Ambiguous = 300;
Equivalent to HTTP status 300. Indicates that multiple representations, each with a specific location, correspond to the requested resource. Agent-driven negotiation information is provided so that the request may be redirected by the user (or user agent) to the location of the preferred representation.[Note: The default action is to treat this status as a redirect and follow the contents of the Location header associated with the current response.
System.Net.HttpStatusCode.Ambiguous is a synonym for System.Net.HttpStatusCode.MultipleChoices.
For a detailed description of the HTTP status code 300, see Section 10.3.1 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
BadGateway = 502;
Equivalent to HTTP status 502. Indicates that the server, acting as a gateway or proxy, received an invalid response from the upstream server that was accessed while attempting to fulfill the request.[Note: For a detailed description of the HTTP status code 502, see Section 10.5.3 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
BadRequest = 400;
Equivalent to HTTP status 400. Indicates that improper syntax prevented the server from understanding the request .[Note: For a detailed description of the HTTP status code 400, see Section 10.4.1 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
Conflict = 409;
Equivalent to HTTP status 409. Indicates that a conflict with the current resource state prevented the completion of the request.[Note: For a detailed description of the HTTP status code 409, see Section 10.4.10 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Continue = 100;
Equivalent to HTTP status 100. Indicates that the client is allowed to continue with the request.[Note: For a detailed description of HTTP status code 100, see Section 10.1.1 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Created = 201;
Equivalent to HTTP status 201. Indicates that the request has been fulfilled, resulting in the creation of a new resource. The most specific URI for this resource is contained by the Location header field of the response.[Note: For a detailed description of the HTTP status code 201, see Section 10.2.2 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
ExpectationFailed = 417;
Equivalent to HTTP status 417. Indicates that the Expect request-header field condition could not be met by the server, or the server is a proxy and has unambiguous evidence that the next-hop server cannot meet the condition.[Note: For a detailed description of the HTTP status code 417, see Section 10.4.18 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Forbidden = 403;
Equivalent to HTTP status 403. Indicates that the server understood but refuses to fulfill the request.[Note: For a detailed description of the HTTP status code 403, see Section 10.4.4 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Found = 302;
Equivalent to HTTP status 302. Indicates that the requested resource is temporarily located on a different URI.[Note: System.Net.HttpStatusCode.Found is a synonym for System.Net.HttpStatusCode.Redirect.
The default action when this status is received is to follow the Location header of the response. When the original request method was POST, the redirected request will use the GET method.
For a detailed description of the HTTP status code 302, see Section 10.3.3 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
GatewayTimeout = 504;
Equivalent to HTTP status 504. Indicates that the server, acting as a gateway or proxy, timed out while waiting for a response from an upstream server accessed in an attempt to fulfill the request.[Note: For a detailed description of the HTTP status code 504, see Section 10.5.5 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Gone = 410;
Equivalent to HTTP status 410. Indicates both that the requested resource is no longer available on the server and no forwarding address is known.[Note: For a detailed description of the HTTP status code 410, see Section 10.4.11 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
HttpVersionNotSupported = 505;
Equivalent to HTTP status 505. Indicates that the HTTP protocol version used by the request is not supported by the server.[Note: For a detailed description of the HTTP status code 505, see Section 10.5.6 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
InternalServerError = 500;
Equivalent to HTTP status 500. Indicates that the request could not be fulfilled by the server due to an unexpected condition.[Note: For a detailed description of the HTTP status code 500, see Section 10.5.1 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
LengthRequired = 411;
Equivalent to HTTP status 411. Indicates that the server refuses to accept the request because its Content-length header is undefined.[Note: For a detailed description of the HTTP status code 411, see Section 10.4.12 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
MethodNotAllowed = 405;
Equivalent to HTTP status 405. Indicates that the method specified in the Request-Line is not allowed for the requested resource.[Note: For a detailed description of the HTTP status code 405, see Section 10.4.6 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Moved = 301;
Equivalent to HTTP status 301. Indicates that a new, permanent URI has been assigned to the requested resource. All future references should use one of the returned URIs.[Note: The default action when this status is received is to follow the Location header of the response. When the original request method was POST, the redirected request will use the GET method.
System.Net.HttpStatusCode.Moved is a synonym for System.Net.HttpStatusCode.MovedPermanently.
For a detailed description of the HTTP status code 301, see Section 10.3.2 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
MovedPermanently = 301;
Equivalent to HTTP status 301. Indicates that a new, permanent URI has been assigned to the requested resource. All future references should use one of the returned URIs.[Note: The default action when this status is received is to follow the Location header of the response.
System.Net.HttpStatusCode.MovedPermanently is a synonym for System.Net.HttpStatusCode.Moved.
For a detailed description of the HTTP status code 301, see Section 10.3.2 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
MultipleChoices = 300;
Equivalent to HTTP status 300. Indicates that multiple representations, each with a specific location, correspond to the requested resource. Agent-driven negotiation information is provided so that the request may be redirected by the user (or user agent) to the location of the preferred representation.[Note: The default action is to treat this status as a redirect and follow the contents of the Location header of the response.
System.Net.HttpStatusCode.MultipleChoices is a synonym for System.Net.HttpStatusCode.Ambiguous.
For a detailed description of the HTTP status code 300, see Section 10.3.1 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
NoContent = 204;
Equivalent to HTTP status 204. Indicates that the request has been fulfilled by the server and no entity-body was returned by the server.[Note: For a detailed description of the HTTP status code 204, see Section 10.2.5 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
NonAuthoritativeInformation = 203;
Equivalent to HTTP status 203. Indicates that a local or a third-party copy rather than the origin server provided the metainformation returned in the entity-header.[Note: For a detailed description of the HTTP status code 203, see Section 10.2.4 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
NotAcceptable = 406;
Equivalent to HTTP status 406. Indicates that the only response entities that can be generated by the requested resource have content characteristics that are not acceptable according to the accept headers sent in the request.[Note: For a detailed description of the HTTP status code 406, see Section 10.4.7 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
NotFound = 404;
Equivalent to HTTP status 404. Indicates that the server did not find a resource that matches the requested URI.[Note: For a detailed description of the HTTP status code 404, see Section 10.4.5 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
NotImplemented = 501;
Equivalent to HTTP status 501. Indicates that the functionality required to fulfill the request is not supported by the server. This is appropriate, for example, if the server does not recognize the request method and cannot support it for any resource.[Note: For a detailed description of the HTTP status code 501, see Section 10.5.2 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
NotModified = 304;
Equivalent to HTTP status 304. Indicates that the client has performed a conditional GET request and access is allowed, but the document has not been modified.[Note: For a detailed description of the HTTP status code 304, see Section 10.3.5 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
OK = 200;
Equivalent to HTTP status 200. Indicates that the request succeeded. The method used by the request determines the information returned with the response as described in the following table.
[Note: For a detailed description of the HTTP status code 200, see Section 10.2.1 of IETF RFC 2616 - HTTP/1.1.]
Method Information returned GET The entity that corresponds to the requested resource. HEAD The entity-header fields that correspond to the requested resource. Does not return the message-body. POST An entity that contains or describes the result of the action. TRACE An entity that contains the request message received by the server.
System.Net.HttpStatusCode Enum, System.Net Namespace
PartialContent = 206;
Equivalent to HTTP status 206. Indicates that the server has fulfilled a partial GET request for the resource. The request is required to have included a Range header field that indicates the desired range.[Note: For a detailed description of the HTTP status code 206, see Section 10.2.7 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
PaymentRequired = 402;
Equivalent to HTTP status 402. System.Net.HttpStatusCode.PaymentRequired is reserved for future use.
System.Net.HttpStatusCode Enum, System.Net Namespace
PreconditionFailed = 412;
Equivalent to HTTP status 412. Indicates that a precondition given in one or more of the request-header fields was tested on the server but evaluated to false.[Note: Conditions are set with conditional request headers such as If-Match, If-None-Match, or If-Unmodified-Since.
For a detailed description of the HTTP status code 412, see Section 10.4.13 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
ProxyAuthenticationRequired = 407;
Equivalent to HTTP status 407. Indicates that the client is required to authenticate itself to the proxy before proceeding.[Note: The Proxy-authenticate header contains the details of how to perform the authentication.
For a detailed description of the HTTP status code 407, see Section 10.4.8 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
Redirect = 302;
Equivalent to HTTP status 302. Indicates that the requested resource is temporarily located on a different URI.[Note: The default action when this status is received is to follow the Location header of the response. When the original request method was POST, the redirected request will use the GET method.
System.Net.HttpStatusCode.Redirect is a synonym for System.Net.HttpStatusCode.Found.
For a detailed description of the HTTP status code 302, see Section 10.3.3 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
RedirectKeepVerb = 307;
Equivalent to HTTP status 307. Indicates that the requested resource is temporarily located under a different URI.[Note: 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.
System.Net.HttpStatusCode.RedirectKeepVerb is a synonym for System.Net.HttpStatusCode.TemporaryRedirect.
For a detailed description of the HTTP status code 307, see Section 10.3.8 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
RedirectMethod = 303;
Equivalent to HTTP status 303. Automatically redirects the client to the URI specified in the Location header as the result of a POST.[Note: The request to the resource specified by the Location header will be made with a GET.
System.Net.HttpStatusCode.RedirectMethod is a synonym for System.Net.HttpStatusCode.SeeOther.
For a detailed description of the HTTP status code 303, see Section 10.3.4 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
RequestEntityTooLarge = 413;
Equivalent to HTTP status 413. Indicates that the request entity is larger that the server is willing or able to process, so the server is not processing the request.[Note: For a detailed description of the HTTP status code 413, see Section 10.4.14 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
RequestTimeout = 408;
Equivalent to HTTP status 408. Indicates that the server timed out before the client produced a request.[Note: For a detailed description of the HTTP status code 408, see Section 10.4.9 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
RequestUriTooLong = 414;
Equivalent to HTTP status 414. Indicates that the Request-URI is longer than the server will interpret, so the server is not servicing the request.[Note: For a detailed description of the HTTP status code 414, see Section 10.4.15 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
RequestedRangeNotSatisfiable = 416;
Equivalent to HTTP status 416. Indicates that none of the values specified by the Range request-header field overlap the current extent of the selected resource, and no If-Range request-header field was contained by the request.[Note: For a detailed description of the HTTP status code 416, see Section 10.4.17 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
ResetContent = 205;
Equivalent to HTTP status 205. Indicates that the server has fulfilled the request and the document view that yielded the request is to be reset by the user agent.[Note: For a detailed description of the HTTP status code 205, see Section 10.2.6 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
SeeOther = 303;
Equivalent to HTTP status 303. Automatically redirects the client to the URI specified in the Location header as the result of a POST.[Note: The request to the resource specified by the Location header will be made with a GET.
System.Net.HttpStatusCode.SeeOther is a synonym for System.Net.HttpStatusCode.RedirectMethod.
For a detailed description of the HTTP status code 303, see Section 10.3.4 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
ServiceUnavailable = 503;
Equivalent to HTTP status 503. Indicates that a temporary overloading or maintenance of the server is preventing it from handling the request.[Note: For a detailed description of the HTTP status code 503, see Section 10.5.4 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
SwitchingProtocols = 101;
Equivalent to HTTP status 101. Indicates that the server understands and will comply with the client's request to switch the protocol being used by the current connection to the protocols defined by the response's Upgrade header.[Note: For a detailed description of the HTTP status code 101, see Section 10.1.2 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
TemporaryRedirect = 307;
Equivalent to HTTP status 307. Indicates that the requested resource is temporarily located under a different URI.[Note: 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.
System.Net.HttpStatusCode.TemporaryRedirect is a synonym for System.Net.HttpStatusCode.RedirectKeepVerb.
For a detailed description of the HTTP status code 307, see Section 10.3.8 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
Unauthorized = 401;
Equivalent to HTTP status 401. Indicates that user authentication is required for the request.[Note: The WWW-Authenticate header contains the details of how to perform the authentication.
For a detailed description of the HTTP status code 401, see Section 10.4.2 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
UnsupportedMediaType = 415;
Equivalent to HTTP status 415. Indicates that the format of the entity of the request is not supported by the requested resource, so the server did not service the request.[Note: For a detailed description of the HTTP status code 415, see Section 10.4.16 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
Unused = 306;
Equivalent to HTTP status 306.[Note: This status code is not used in HTTP/1.1.
For a detailed description of the HTTP status code 306, see Section 10.3.7 of IETF RFC 2616 - HTTP/1.1.
]
System.Net.HttpStatusCode Enum, System.Net Namespace
UseProxy = 305;
Equivalent to HTTP status 305. Indicates that the requested resource is required to be accessed through the proxy identified in the Location header field.[Note: For a detailed description of the HTTP status code 305, see Section 10.3.6 of IETF RFC 2616 - HTTP/1.1.]
System.Net.HttpStatusCode Enum, System.Net Namespace
value__;
System.Net.HttpStatusCode Enum, System.Net Namespace