HttpWebResponse Class

 

Provides an HTTP-specific implementation of the WebResponse class.

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

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

[<SerializableAttribute>]
type HttpWebResponse = 
    class
        inherit WebResponse
        interface ISerializable
    end

NameDescription
System_CAPS_pubmethodHttpWebResponse()

Obsolete.Initializes a new instance of the HttpWebResponse class.

System_CAPS_protmethodHttpWebResponse(SerializationInfo, StreamingContext)

Obsolete.Initializes a new instance of the HttpWebResponse class from the specified SerializationInfo and StreamingContext instances.

NameDescription
System_CAPS_pubpropertyCharacterSet

Gets the character set of the response.

System_CAPS_pubpropertyContentEncoding

Gets the method that is used to encode the body of the response.

System_CAPS_pubpropertyContentLength

Gets the length of the content returned by the request.(Overrides WebResponse.ContentLength.)

System_CAPS_pubpropertyContentType

Gets the content type of the response.(Overrides WebResponse.ContentType.)

System_CAPS_pubpropertyCookies

Gets or sets the cookies that are associated with this response.

System_CAPS_pubpropertyHeaders

Gets the headers that are associated with this response from the server.(Overrides WebResponse.Headers.)

System_CAPS_pubpropertyIsFromCache

Gets a Boolean value that indicates whether this response was obtained from the cache.(Inherited from WebResponse.)

System_CAPS_pubpropertyIsMutuallyAuthenticated

Gets a Boolean value that indicates whether both client and server were authenticated.(Overrides WebResponse.IsMutuallyAuthenticated.)

System_CAPS_pubpropertyLastModified

Gets the last date and time that the contents of the response were modified.

System_CAPS_pubpropertyMethod

Gets the method that is used to return the response.

System_CAPS_pubpropertyProtocolVersion

Gets the version of the HTTP protocol that is used in the response.

System_CAPS_pubpropertyResponseUri

Gets the URI of the Internet resource that responded to the request.(Overrides WebResponse.ResponseUri.)

System_CAPS_pubpropertyServer

Gets the name of the server that sent the response.

System_CAPS_pubpropertyStatusCode

Gets the status of the response.

System_CAPS_pubpropertyStatusDescription

Gets the status description returned with the response.

System_CAPS_pubpropertySupportsHeaders

Gets a value that indicates if headers are supported.(Overrides WebResponse.SupportsHeaders.)

NameDescription
System_CAPS_pubmethodClose()

Closes the response stream.(Overrides WebResponse.Close().)

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases the unmanaged resources used by the WebResponse object.(Inherited from WebResponse.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the HttpWebResponse, and optionally disposes of the managed resources.(Overrides WebResponse.Dispose(Boolean).)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodGetObjectData(SerializationInfo, StreamingContext)

This API supports the product infrastructure and is not intended to be used directly from your code. Populates a SerializationInfo with the data needed to serialize the target object.(Overrides WebResponse.GetObjectData(SerializationInfo, StreamingContext).)

System_CAPS_pubmethodGetResponseHeader(String)

Gets the contents of a header that was returned with the response.

System_CAPS_pubmethodGetResponseStream()

Gets the stream that is used to read the body of the response from the server.(Overrides WebResponse.GetResponseStream().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISerializable.GetObjectData(SerializationInfo, StreamingContext)

This API supports the product infrastructure and is not intended to be used directly from your code. Serializes this instance into the specified SerializationInfo object.

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.

System_CAPS_noteNote

Do not confuse HttpWebResponse with the HttpResponse class that is used in ASP.NET applications and whose methods and properties are exposed through ASP.NET's intrinsic Response object.

You should never directly create an instance of the HttpWebResponse class. Instead, use the instance returned by a call to HttpWebRequest.GetResponse. You must call either the Stream.Close or the HttpWebResponse.Close method to close the response and release the connection for reuse. It is not necessary to call both Stream.Close and HttpWebResponse.Close, 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. Other headers can be read from the Headers property as name/value pairs.

The following table shows the common HTTP headers that are available through properties of the HttpWebResponse class.

Header

Property

Content-Encoding

ContentEncoding

Content-Length

ContentLength

Content-Type

ContentType

Last-Modified

LastModified

Server

Server

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

The following example returns an HttpWebResponse from an HttpWebRequest.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

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

Return to top
Show: