HttpWebResponse Class

Provides an HTTP-specific implementation of the WebResponse class.

Inheritance Hierarchy

System.Object
  System.Net.WebResponse
    System.Net.HttpWebResponse

Namespace:  System.Net
Assembly:  System.Net (in System.Net.dll)

Syntax

'Declaration
Public MustInherit Class HttpWebResponse _
    Inherits WebResponse
public abstract class HttpWebResponse : WebResponse

The HttpWebResponse type exposes the following members.

Constructors

  Name Description
Protected methodSupported by Silverlight for Windows Phone HttpWebResponse Initializes a new instance of the WebResponse class.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone ContentLength When overridden in a descendant class, gets or sets the content length of data being received. (Inherited from WebResponse.)

In Silverlight for Windows Phone, this member is overridden by ContentLength.

In XNA Framework, this member is overridden by ContentLength.
Public propertySupported by Silverlight for Windows Phone ContentType When overridden in a derived class, gets or sets the content type of the data being received. (Inherited from WebResponse.)

In Silverlight for Windows Phone, this member is overridden by ContentType.

In XNA Framework, this member is overridden by ContentType.
Public propertySupported by Silverlight for Windows Phone Cookies Gets the cookies used to persist state information for the HTTP response.
Public propertySupported by Silverlight for Windows Phone Headers When overridden in a derived class, gets a collection of header name-value pairs associated with this request. (Inherited from WebResponse.)

In Silverlight for Windows Phone, this member is overridden by Headers.

In XNA Framework, this member is overridden by Headers.
Public propertySupported by Silverlight for Windows Phone Method Gets the method that is used to return the response.
Public propertySupported by Silverlight for Windows Phone ResponseUri When overridden in a derived class, gets the URI of the Internet resource that actually responded to the request. (Inherited from WebResponse.)

In Silverlight for Windows Phone, this member is overridden by ResponseUri.

In XNA Framework, this member is overridden by ResponseUri.
Public propertySupported by Silverlight for Windows Phone StatusCode Gets the status of the response.
Public propertySupported by Silverlight for Windows Phone StatusDescription Gets the status description returned with the response.
Public propertySupported by Silverlight for Windows Phone SupportsHeaders Gets a value that indicates whether the Headers property is supported by the descendant class for the WebResponse instance. (Inherited from WebResponse.)

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Close When overridden by a descendant class, closes the response stream. (Inherited from WebResponse.)

In Silverlight for Windows Phone, this member is overridden by Close().

In XNA Framework, this member is overridden by Close().
Public methodSupported by Silverlight for Windows Phone Dispose() Releases the resources used by the current instance of the WebResponse class. (Inherited from WebResponse.)
Protected methodSupported by Silverlight for Windows Phone Dispose(Boolean) Called by the Dispose() and Finalize() methods to release the managed and unmanaged resources used by the current instance of the WebResponse class. (Inherited from WebResponse.)

In Silverlight for Windows Phone Windows Phone OS 7.1, this member is Dispose(Boolean).
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetResponseStream When overridden in a descendant class, returns the data stream from the Internet resource. (Inherited from WebResponse.)

In Silverlight for Windows Phone, this member is overridden by GetResponseStream().

In XNA Framework, this member is overridden by GetResponseStream().
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows Phone IDisposable.Dispose Infrastructure. Releases all resources used by the HttpWebResponse.

Top

Remarks

This class contains support for HTTP-specific uses of the properties and methods of the WebResponse class. The HttpWebResponse class is used to build HTTP stand-alone client applications that send HTTP requests and receive HTTP responses.

You should never directly create an instance of the HttpWebResponse class. Instead, use the instance returned by a call to HttpWebRequest.BeginGetResponse.

You must call either the Close or Stream.Close method to close the response and release the connection for reuse. It is not necessary to call both the Close and the Stream.Close method, but doing so does not cause an error.

Common header information returned from the Internet resource is exposed as properties of the class. See the following table for a complete list. Headers for the request can be read from the Headers property as name/value pairs.

The following table shows the values that are available through properties of the HttpWebResponse class.

Header

Property

HTTP method

Method

Status code

StatusCode

Status description

StatusDescription

The contents of the response from the Internet resource are returned as a Stream by calling the GetResponseStream method.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 This type is not abstract in Silverlight for Windows Phone.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference