HttpWebResponse Class

HttpWebResponse Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Provides an HTTP-specific implementation of the WebResponse class.


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

public class HttpWebResponse : WebResponse, 

The HttpWebResponse type exposes the following members.

Protected methodHttpWebResponseInitializes a new instance of the WebResponse class.

Public propertyContentLengthGets the length of the content returned by the request. (Overrides WebResponse.ContentLength.)
Public propertyContentTypeGets the content type of the response. (Overrides WebResponse.ContentType.)
Public propertyCookiesGets the cookies used to persist state information for the HTTP response.
Public propertyHeadersGets the headers that are associated with this response from the server. (Overrides WebResponse.Headers.)
Public propertyMethodGets the method that is used to return the response.
Public propertyResponseUriGets the URI of the Internet resource that responded to the request. (Overrides WebResponse.ResponseUri.)
Public propertyStatusCodeGets the status of the response.
Public propertyStatusDescriptionGets the status description returned with the response.
Public propertySupportsHeadersGets a value that indicates if headers are supported. (Overrides WebResponse.SupportsHeaders.)

Public methodCloseCloses the response stream. (Overrides WebResponse.Close().)
Public methodDispose()Releases the resources used by the current instance of the WebResponse class. (Inherited from WebResponse.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the HttpWebResponse and optionally releases the managed resources. (Overrides WebResponse.Dispose(Boolean).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetResponseStreamGets the stream that is used to read the body of the response from the server. (Overrides WebResponse.GetResponseStream().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Explicit interface implemetationPrivate methodIDisposable.DisposeInfrastructure. Releases all resources used by the HttpWebResponse.

This class contains support for HTTP-specific uses of the properties and methods of the WebResponse class. The HttpWebResponse class is used to build 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.



HTTP method


Status code


Status description


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


If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.


Windows Phone 8, Windows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone 8.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

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

© 2017 Microsoft