Accessing Additional HTTP Response Information


When using HttpWebResponse, you have access to information other than the content of the specified resource. This information includes such things as the time the resource was last modified and the name of the server, and is available through various properties associated with the response. These properties, which include the six defined by WebResponse, are shown in Table 24-5. The following sections illustrate how to use representative samples.

Table 24-5: The Properties Defined by HttpWebResponse

Property

Description

public string CharacterSet { get; }

Obtains the name of the character set being used.

public string ContentEncoding { get; }

Obtains the name of the encoding scheme.

public long ContentLength { get; }

Obtains the length of the content being received. This will be 1 if the content length is not available.

public string ContentType { get; }

Obtains a description of the content.

public CookieCollection Cookies { get; set; }

Obtains or sets a list of the cookies attached to the response.

public WebHeaderCollection Headers{ get; }

Obtains a collection of the headers attached to the response.

public virtual bool IsFromCache { get; }

If the response came from the cache, this property is true. It is false if the response was delivered over the network. (Added by C# 2.0.)

public bool IsMutuallyAuthenticated { get; }

If the client and server are both authenticated, then this property is true.

It is false otherwise. (Added by C# 2.0.)

public DateTime LastModified { get; }

Obtains the time at which the resource was last changed.

public string Method { get; }

Obtains a string that specifies the response method.

public Version ProtocolVersion { get; }

Obtains a Version object that describes the version of HTTP used in the transaction.

public Uri ReponseUri { get; }

Obtains the URI that generated the response. This may differ from the one requested if the response was redirected to another URI.

public string Server { get; }

Obtains a string that represents the name of the server.

public HttpStatusCode StatusCode { get; }

Obtains an HttpStatusCode object that describes the status of the transaction.

public string StatusDescription { get; }

Obtains a string that represents the status of the transaction in a human-readable form.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

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