System.Net.HttpStatusCode Enum

public enum HttpStatusCode

Base Types

Object
  ValueType
    Enum
      HttpStatusCode

Assembly

System

Library

Networking

Summary

Contains the values of status codes defined for the Hypertext Transfer Protocol (HTTP).

Description

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.

]

Example

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.

See Also

System.Net Namespace

Members

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


HttpStatusCode.Accepted Field

Accepted = 202;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Ambiguous Field

Ambiguous = 300;

Summary

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 can 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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.BadGateway Field

BadGateway = 502;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.BadRequest Field

BadRequest = 400;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Conflict Field

Conflict = 409;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Continue Field

Continue = 100;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Created Field

Created = 201;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.ExpectationFailed Field

ExpectationFailed = 417;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Forbidden Field

Forbidden = 403;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Found Field

Found = 302;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.GatewayTimeout Field

GatewayTimeout = 504;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Gone Field

Gone = 410;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.HttpVersionNotSupported Field

HttpVersionNotSupported = 505;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.InternalServerError Field

InternalServerError = 500;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.LengthRequired Field

LengthRequired = 411;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.MethodNotAllowed Field

MethodNotAllowed = 405;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Moved Field

Moved = 301;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.MovedPermanently Field

MovedPermanently = 301;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.MultipleChoices Field

MultipleChoices = 300;

Summary

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 can 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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.NoContent Field

NoContent = 204;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.NonAuthoritativeInformation Field

NonAuthoritativeInformation = 203;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.NotAcceptable Field

NotAcceptable = 406;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.NotFound Field

NotFound = 404;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.NotImplemented Field

NotImplemented = 501;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.NotModified Field

NotModified = 304;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.OK Field

OK = 200;

Summary

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.

MethodInformation 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.
[Note: For a detailed description of the HTTP status code 200, see Section 10.2.1 of IETF RFC 2616 - HTTP/1.1.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.PartialContent Field

PartialContent = 206;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.PaymentRequired Field

PaymentRequired = 402;

Summary

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

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.PreconditionFailed Field

PreconditionFailed = 412;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.ProxyAuthenticationRequired Field

ProxyAuthenticationRequired = 407;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Redirect Field

Redirect = 302;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.RedirectKeepVerb Field

RedirectKeepVerb = 307;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.RedirectMethod Field

RedirectMethod = 303;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.RequestEntityTooLarge Field

RequestEntityTooLarge = 413;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.RequestTimeout Field

RequestTimeout = 408;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.RequestUriTooLong Field

RequestUriTooLong = 414;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.RequestedRangeNotSatisfiable Field

RequestedRangeNotSatisfiable = 416;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.ResetContent Field

ResetContent = 205;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.SeeOther Field

SeeOther = 303;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.ServiceUnavailable Field

ServiceUnavailable = 503;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.SwitchingProtocols Field

SwitchingProtocols = 101;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.TemporaryRedirect Field

TemporaryRedirect = 307;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Unauthorized Field

Unauthorized = 401;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.UnsupportedMediaType Field

UnsupportedMediaType = 415;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.Unused Field

Unused = 306;

Summary

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.

]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.UseProxy Field

UseProxy = 305;

Summary

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.]

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace

HttpStatusCode.value__ Field

value__;

See Also

System.Net.HttpStatusCode Enum, System.Net Namespace