System.Net Errors

It is important that you be able to correctly identify anything that goes wrong with your networked applications. For that reason, this entire section is dedicated to presenting a comprehensive guide to System.Net errors. Table 13.3 contains all the HttpStatusCode enumeration values. These values don't necessarilyrepresent errors, but in many cases they do. This table presents the status codes that can be returned from networking method calls.

Table 13.4 contains the WebExceptionStatus enumeration. All exceptions that the System.Net methods throw can be found in this table. These are the values that you must check when your System.Net throws an exception.

Table 13.3. The HttpStatusCode Enumeration

Member Name

Description

Accepted

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

Ambiguous

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. If the HttpWebRequest.AllowAutoRedirect property is false, Ambiguous causes an exception to be thrown. Ambiguous is a synonym for MultipleChoices.

BadGateway

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

BadRequest

Equivalent to HTTP status 400. BadRequest indicates that the server could not understand the request. 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. Conflict indicates that the request could not be carried out because of a conflict on the server.

Continue

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

Created

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

ExpectationFailed

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

Forbidden

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

Found

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 is POST, the redirected request uses the GET method. If the HttpWebRequest.AllowAutoRedirect property is false, Found causes an exception to be thrown. Found is a synonym for Redirect.

GatewayTimeout

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

Gone

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

HttpVersionNotSupported

Equivalent to HTTP status 505. HttpVersion NotSupported indicates that the server does not support the requested HTTP version.

InternalServerError

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

LengthRequired

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

MethodNotAllowed

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

Moved

Equivalent to HTTP status 302. 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 (the location that it specifies) associated with the response. When the original request method was POST, the redirected request uses the GET method. If the HttpWebRequest.AllowAutoRedirect property is false, Moved causes an exception to be thrown. Moved is a synonym for MovedPermanently.

MovedPermanently

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. If the HttpWebRequest.AllowAutoRedirect property is false, MovedPermanently causes an exception to be thrown. MovedPermanently is a synonym for Moved.

MultipleChoices

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 (the location that is specified) associated with this response. If the HttpWebRequest.AllowAutoRedirect property is false, MultipleChoices causes an exception to be thrown. MultipleChoices is a synonym for Ambiguous.

NoContent

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

NonAuthoritativeInformation

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

NotAcceptable

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.

NotFound

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

NotImplemented

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

NotModified

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

Equivalent to HTTP status 200. 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. 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. PaymentRequired is reserved for future use.

PreconditionFailed

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 such as If-Match, If-None-Match, or If-Unmodified-Since.

ProxyAuthenticationRequired

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

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 uses the GET method. If the HttpWebRequest.AllowAutoRedirect property is false, Redirect causes an exception to be thrown. Redirect is a synonym for Found.

RedirectKeepVerb

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 (redirect to the location it specifies) associated with the response. When the original request method is POST, the redirected request also uses the POST method. If the HttpWebRequest.AllowAutoRedirect property is false, RedirectKeepVerb causes an exception to be thrown. RedirectKeepVerb is a synonym for TemporaryRedirect.

RedirectMethod

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 that the Location header specifies is made with a GET. If the HttpWebRequest.AllowAutoRedirect property is false, RedirectMethod causes an exception to be thrown. RedirectMethod is a synonym for SeeOther.

RequestedRangeNotSatisfiable

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

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

RequestTimeout

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

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

ResetContent

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

SeeOther

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 that the Location header specifies is made with a GET. If the HttpWebRequest.AllowAutoRedirect property is false, SeeOther causes an exception to be thrown. SeeOther is a synonym for RedirectMethod.

ServiceUnavailable

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

SwitchingProtocols

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

TemporaryRedirect

Equivalent to HTTP status 307. TemporaryRedirect 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 (or redirect to what is specified) associated with the response. When the original request method is POST, the redirected request also uses the POST method. If the HttpWebRequest.AllowAutoRedirect property is false, TemporaryRedirect causes an exception to be thrown. TemporaryRedirect is a synonym for RedirectKeepVerb.

Unauthorized

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.

UnsupportedMediaType

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

Unused

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

UseProxy

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

Table is excerpted from MSDN and is copyrighted by Microsoft.

Table 13.4. The WebExceptionStatus Enumeration

Member Name

Description

ConnectFailure

The remote service point could not be contacted at the transport level.

ConnectionClosed

The connection was prematurely closed.

KeepAliveFailure

The connection for a request that specifies the Keep-alive header was closed unexpectedly.

NameResolutionFailure

The name-resolver service could not resolve the host name.

Pending

An internal asynchronous request is pending.

PipelineFailure

This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.

ProtocolError

The response received from the server was complete but indicated a protocol-level error. For example, an HTTP protocol error such as 401 Access Denied would use this status.

ProxyNameResolutionFailure

The name-resolver service could not resolve the proxy host name.

ReceiveFailure

A complete response was not received from the remote server.

RequestCanceled

The request was canceled, the WebRequest.Abort method was called, or an unclassifiable error occurred. This is the default value for Status.

SecureChannelFailure

An error occurred in a secure channel link.

SendFailure

A complete request could not be sent to the remote server.

ServerProtocolViolation

The server response was not a valid HTTP response.

Success

No error was encountered.

Timeout

No response was received during the time-out period for a request.

TrustFailure

A server certificate could not be validated.

Table is excerpted from MSDN and is copyrighted by Microsoft.



ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ISBN: 321159659
EAN: N/A
Year: 2003
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net