WebResponse WebResponse WebResponse WebResponse Class

Definition

Provides a response from a Uniform Resource Identifier (URI). This is an abstract class.

public ref class WebResponse abstract : MarshalByRefObject, IDisposable, System::Runtime::Serialization::ISerializable
public abstract class WebResponse : MarshalByRefObject, IDisposable, System.Runtime.Serialization.ISerializable
type WebResponse = class
    inherit MarshalByRefObject
    interface ISerializable
    interface IDisposable
Public MustInherit Class WebResponse
Inherits MarshalByRefObject
Implements IDisposable, ISerializable
Inheritance
Derived
Implements

Examples

The following example creates a WebResponse instance from a WebRequest.

// Initialize the WebRequest.
WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" );

// Return the response. 
WebResponse^ myResponse = myRequest->GetResponse();

// Code to use the WebResponse goes here.

// Close the response to free resources.
myResponse->Close();
// Initialize the WebRequest.
WebRequest myRequest = WebRequest.Create("http://www.contoso.com");

// Return the response. 
WebResponse myResponse = myRequest.GetResponse();

// Code to use the WebResponse goes here.

// Close the response to free resources.
myResponse.Close();

' Initialize the WebRequest.
Dim myRequest As WebRequest = WebRequest.Create("http://www.contoso.com")

' Return the response. 
Dim myResponse As WebResponse = myRequest.GetResponse()

' Code to use the WebResponse goes here.
' Close the response to free resources.
myResponse.Close()

Remarks

The WebResponse class is the abstract base class from which protocol-specific response classes are derived. Applications can participate in request and response transactions in a protocol-agnostic manner using instances of the WebResponse class while protocol-specific classes derived from WebResponse carry out the details of the request.

Client applications do not create WebResponse objects directly; they are created by calling the GetResponse method on a WebRequest instance.

Notes to Inheritors

When you inherit from WebResponse, you must override the following members: ContentLength, ContentType, GetResponseStream(), ResponseUri, and Headers.

Constructors

WebResponse() WebResponse() WebResponse() WebResponse()

Initializes a new instance of the WebResponse class.

WebResponse(SerializationInfo, StreamingContext) WebResponse(SerializationInfo, StreamingContext) WebResponse(SerializationInfo, StreamingContext) WebResponse(SerializationInfo, StreamingContext)

Initializes a new instance of the WebResponse class from the specified instances of the SerializationInfo and StreamingContext classes.

Properties

ContentLength ContentLength ContentLength ContentLength

When overridden in a descendant class, gets or sets the content length of data being received.

ContentType ContentType ContentType ContentType

When overridden in a derived class, gets or sets the content type of the data being received.

Headers Headers Headers Headers

When overridden in a derived class, gets a collection of header name-value pairs associated with this request.

IsFromCache IsFromCache IsFromCache IsFromCache

Gets a Boolean value that indicates whether this response was obtained from the cache.

IsMutuallyAuthenticated IsMutuallyAuthenticated IsMutuallyAuthenticated IsMutuallyAuthenticated

Gets a Boolean value that indicates whether mutual authentication occurred.

ResponseUri ResponseUri ResponseUri ResponseUri

When overridden in a derived class, gets the URI of the Internet resource that actually responded to the request.

SupportsHeaders SupportsHeaders SupportsHeaders SupportsHeaders

Gets a value that indicates if headers are supported.

Methods

Close() Close() Close() Close()

When overridden by a descendant class, closes the response stream.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(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)
Dispose() Dispose() Dispose() Dispose()

Releases the unmanaged resources used by the WebResponse object.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the WebResponse object, and optionally disposes of the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo with the data that is needed to serialize the target object.

GetResponseStream() GetResponseStream() GetResponseStream() GetResponseStream()

When overridden in a descendant class, returns the data stream from the Internet resource.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

When overridden in a derived class, releases all resources used by the WebResponse.

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo instance with the data that is needed to serialize WebResponse.

Applies to