状态代码 状态信息 含义
100 Continue 初始的请求已经接受,客户应当继续发送请求的其余部分。(HTTP 1.1新)
101 Switching Protocols 服务器将遵从客户的请求转换到另外一种协议(HTTP 1.1新
200 OK 一切正常,对GET和POST请求的应答文档跟在后面。
201 Created 服务器已经创建了文档,Location头给出了它的URL。
202 Accepted 已经接受请求,但处理尚未完成。
203 Non-Authoritative Information 文档已经正常地返回,但一些应答头可能不正确,因为使用的是文档的拷贝(HTTP 1.1新)。
204 No Content 没有新文档,浏览器应该继续显示原来的文档。
205 Reset Content 没有新的内容,但浏览器应该重置它所显示的内容。用来强制浏览器清除表单输入内容(HTTP 1.1新)。
206 Partial Content 客户发送了一个带有Range头的GET请求,服务器完成了它(HTTP 1.1新)。
300 Multiple Choices 客户请求的文档可以在多个位置找到,这些位置已经在返回的文档内列出。如果服务器要提出优先选择,则应该在Location应答头指明。
301 Moved Permanently 客户请求的文档在其他地方,新的URL在Location头中给出,浏览器应该自动地访问新的URL。
302 Found 类似于301,但新的URL应该被视为临时性的替代,而不是永久性的。注意,在HTTP1.0中对应的状态信息是“Moved Temporatily”,出现该状态代码时,浏览器能够自动访问新的URL,因此它是一个很有用的状态代码。注意这个状态代码有时候可以和301替换使用。例如,如果浏览器错误地请求http://host/~user(缺少了后面的斜杠),有的服务器返回301,有的则返回302。严格地说,我们只能假定只有当原来的请求是GET时浏览器才会自动重定向。请参见307。
303 See Other 类似于301/302,不同之处在于,如果原来的请求是POST,Location头指定的重定向目标文档应该通过GET提取(HTTP 1.1新)。
304 Not Modified 客户端有缓冲的文档并发出了一个条件性的请求(一般是提供If-Modified-Since头表示客户只想比指定日期更新的文档)。服务器告诉客户,原来缓冲的文档还可以继续使用。
305 Use Proxy 客户请求的文档应该通过Location头所指明的代理服务器提取(HTTP 1.1新)。
307 Temporary Redirect 和302(Found)相同。许多浏览器会错误地响应302应答进行重定向,即使原来的请求是POST,即使它实际上只能在POST请求的应答是303时才能重定向。由于这个原因,HTTP 1.1新增了307,以便更加清除地区分几个状态代码:当出现303应答时,浏览器可以跟随重定向的GET和POST请求;如果是307应答,则浏览器只能跟随对GET请求的重定向。(HTTP 1.1新)
400 Bad Request 请求出现语法错误。
401 Unauthorized 客户试图未经授权访问受密码保护的页面。应答中会包含一个WWW-Authenticate头,浏览器据此显示用户名字/密码对话框,然后在填写合适的Authorization头后再次发出请求。
403 Forbidden 资源不可用。服务器理解客户的请求,但拒绝处理它。通常由于服务器上文件或目录的权限设置导致。
404 Not Found 无法找到指定位置的资源。这也是一个常用的应答,
405 Method Not Allowed 请求方法(GET、POST、HEAD、DELETE、PUT、TRACE等)对指定的资源不适用。(HTTP 1.1新)
406 Not Acceptable 指定的资源已经找到,但它的MIME类型和客户在Accpet头中所指定的不兼容(HTTP 1.1新)。
407 Prox Authentication Required 类似于401,表示客户必须先经过代理服务器的授权。(HTTP 1.1新)
408 Request Timeout 在服务器许可的等待时间内,客户一直没有发出任何请求。客户可以在以后重复同一请求。(HTTP 1.1新)
409 Conflict 通常和PUT请求有关。由于请求和资源的当前状态相冲突,因此请求不能成功。(HTTP 1.1新)
410 Gone 所请求的文档已经不再可用,而且服务器不知道应该重定向到哪一个地址。它和404的不同在于,返回407表示文档永久地离开了指定的位置,而404表示由于未知的原因文档不可用。(HTTP 1.1新)
411 Length Required 服务器不能处理请求,除非客户发送一个Content-Length头。(HTTP 1.1新)
412 Precondition Failed 请求头中指定的一些前提条件失败(HTTP 1.1新)。
413 Request Entity Too Large 目标文档的大小超过服务器当前愿意处理的大小。如果服务器认为自己能够稍后再处理该请求,则应该提供一个Retry-After头(HTTP 1.1新)。
414 Request URI Too Long URI太长(HTTP 1.1新)。
416 Requested Range Not Satisfiable 服务器不能满足客户在请求中指定的Range头。(HTTP 1.1新)
500 Internal Server Error 服务器遇到了意料不到的情况,不能完成客户的请求。
501 Not Implemented 服务器不支持实现请求所需要的功能。例如,客户发出了一个服务器不支持的PUT请求。
502 Bad Gateway 服务器作为网关或者代理时,为了完成请求访问下一个服务器,但该服务器返回了非法的应答。
503 Service Unavailable 服务器由于维护或者负载过重未能应答。
504 Gateway Timeout 由作为代理或网关的服务器使用,表示不能及时地从远程服务器获得应答。(HTTP 1.1新)
505 HTTP Version Not Supported 服务器不支持请求中所指明的HTTP版本
using System; namespace System.Net { // Summary: // Contains the values of status codes defined for HTTP. public enum HttpStatusCode { // Summary: // Equivalent to HTTP status 100. System.Net.HttpStatusCode.Continue indicates // that the client can continue with its request. Continue = 100, // // Summary: // Equivalent to HTTP status 101. System.Net.HttpStatusCode.SwitchingProtocols // indicates that the protocol version or protocol is being changed. SwitchingProtocols = 101, // // Summary: // Equivalent to HTTP status 200. System.Net.HttpStatusCode.OK indicates that // the request succeeded and that the requested information is in the response. // This is the most common status code to receive. OK = 200, // // Summary: // Equivalent to HTTP status 201. System.Net.HttpStatusCode.Created indicates // that the request resulted in a new resource created before the response was // sent. Created = 201, // // Summary: // Equivalent to HTTP status 202. System.Net.HttpStatusCode.Accepted indicates // that the request has been accepted for further processing. Accepted = 202, // // Summary: // Equivalent to HTTP status 203. System.Net.HttpStatusCode.NonAuthoritativeInformation // indicates that the returned metainformation is from a cached copy instead // of the origin server and therefore may be incorrect. NonAuthoritativeInformation = 203, // // Summary: // Equivalent to HTTP status 204. System.Net.HttpStatusCode.NoContent indicates // that the request has been successfully processed and that the response is // intentionally blank. NoContent = 204, // // Summary: // Equivalent to HTTP status 205. System.Net.HttpStatusCode.ResetContent indicates // that the client should reset (not reload) the current resource. ResetContent = 205, // // Summary: // Equivalent to HTTP status 206. System.Net.HttpStatusCode.PartialContent indicates // that the response is a partial response as requested by a GET request that // includes a byte range. PartialContent = 206, // // Summary: // Equivalent to HTTP status 300. System.Net.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. MultipleChoices = 300, // // Summary: // Equivalent to HTTP status 300. System.Net.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. Ambiguous = 300, // // Summary: // Equivalent to HTTP status 301. System.Net.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. MovedPermanently = 301, // // Summary: // Equivalent to HTTP status 301. System.Net.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. Moved = 301, // // Summary: // Equivalent to HTTP status 302. System.Net.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. Found = 302, // // Summary: // Equivalent to HTTP status 302. System.Net.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. Redirect = 302, // // Summary: // Equivalent to HTTP status 303. System.Net.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. SeeOther = 303, // // Summary: // Equivalent to HTTP status 303. System.Net.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. RedirectMethod = 303, // // Summary: // Equivalent to HTTP status 304. System.Net.HttpStatusCode.NotModified indicates // that the client's cached copy is up to date. The contents of the resource // are not transferred. NotModified = 304, // // Summary: // Equivalent to HTTP status 305. System.Net.HttpStatusCode.UseProxy indicates // that the request should use the proxy server at the URI specified in the // Location header. UseProxy = 305, // // Summary: // Equivalent to HTTP status 306. System.Net.HttpStatusCode.Unused is a proposed // extension to the HTTP/1.1 specification that is not fully specified. Unused = 306, // // Summary: // Equivalent to HTTP status 307. System.Net.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. TemporaryRedirect = 307, // // Summary: // Equivalent to HTTP status 307. System.Net.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. RedirectKeepVerb = 307, // // Summary: // Equivalent to HTTP status 400. System.Net.HttpStatusCode.BadRequest indicates // that the request could not be understood by the server. System.Net.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. BadRequest = 400, // // Summary: // Equivalent to HTTP status 401. System.Net.HttpStatusCode.Unauthorized indicates // that the requested resource requires authentication. The WWW-Authenticate // header contains the details of how to perform the authentication. Unauthorized = 401, // // Summary: // Equivalent to HTTP status 402. System.Net.HttpStatusCode.PaymentRequired // is reserved for future use. PaymentRequired = 402, // // Summary: // Equivalent to HTTP status 403. System.Net.HttpStatusCode.Forbidden indicates // that the server refuses to fulfill the request. Forbidden = 403, // // Summary: // Equivalent to HTTP status 404. System.Net.HttpStatusCode.NotFound indicates // that the requested resource does not exist on the server. NotFound = 404, // // Summary: // Equivalent to HTTP status 405. System.Net.HttpStatusCode.MethodNotAllowed // indicates that the request method (POST or GET) is not allowed on the requested // resource. MethodNotAllowed = 405, // // Summary: // Equivalent to HTTP status 406. System.Net.HttpStatusCode.NotAcceptable indicates // that the client has indicated with Accept headers that it will not accept // any of the available representations of the resource. NotAcceptable = 406, // // Summary: // Equivalent to HTTP status 407. System.Net.HttpStatusCode.ProxyAuthenticationRequired // indicates that the requested proxy requires authentication. The Proxy-authenticate // header contains the details of how to perform the authentication. ProxyAuthenticationRequired = 407, // // Summary: // Equivalent to HTTP status 408. System.Net.HttpStatusCode.RequestTimeout indicates // that the client did not send a request within the time the server was expecting // the request. RequestTimeout = 408, // // Summary: // Equivalent to HTTP status 409. System.Net.HttpStatusCode.Conflict indicates // that the request could not be carried out because of a conflict on the server. Conflict = 409, // // Summary: // Equivalent to HTTP status 410. System.Net.HttpStatusCode.Gone indicates that // the requested resource is no longer available. Gone = 410, // // Summary: // Equivalent to HTTP status 411. System.Net.HttpStatusCode.LengthRequired indicates // that the required Content-length header is missing. LengthRequired = 411, // // Summary: // Equivalent to HTTP status 412. System.Net.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 like // If-Match, If-None-Match, or If-Unmodified-Since. PreconditionFailed = 412, // // Summary: // Equivalent to HTTP status 413. System.Net.HttpStatusCode.RequestEntityTooLarge // indicates that the request is too large for the server to process. RequestEntityTooLarge = 413, // // Summary: // Equivalent to HTTP status 414. System.Net.HttpStatusCode.RequestUriTooLong // indicates that the URI is too long. RequestUriTooLong = 414, // // Summary: // Equivalent to HTTP status 415. System.Net.HttpStatusCode.UnsupportedMediaType // indicates that the request is an unsupported type. UnsupportedMediaType = 415, // // Summary: // Equivalent to HTTP status 416. System.Net.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. RequestedRangeNotSatisfiable = 416, // // Summary: // Equivalent to HTTP status 417. System.Net.HttpStatusCode.ExpectationFailed // indicates that an expectation given in an Expect header could not be met // by the server. ExpectationFailed = 417, // // Summary: // Equivalent to HTTP status 500. System.Net.HttpStatusCode.InternalServerError // indicates that a generic error has occurred on the server. InternalServerError = 500, // // Summary: // Equivalent to HTTP status 501. System.Net.HttpStatusCode.NotImplemented indicates // that the server does not support the requested function. NotImplemented = 501, // // Summary: // Equivalent to HTTP status 502. System.Net.HttpStatusCode.BadGateway indicates // that an intermediate proxy server received a bad response from another proxy // or the origin server. BadGateway = 502, // // Summary: // Equivalent to HTTP status 503. System.Net.HttpStatusCode.ServiceUnavailable // indicates that the server is temporarily unavailable, usually due to high // load or maintenance. ServiceUnavailable = 503, // // Summary: // Equivalent to HTTP status 504. System.Net.HttpStatusCode.GatewayTimeout indicates // that an intermediate proxy server timed out while waiting for a response // from another proxy or the origin server. GatewayTimeout = 504, // // Summary: // Equivalent to HTTP status 505. System.Net.HttpStatusCode.HttpVersionNotSupported // indicates that the requested HTTP version is not supported by the server. HttpVersionNotSupported = 505, } }