Provides a response from a Uniform Resource Identifier (URI). This is an abstract class.
<SerializableAttribute> _ Public MustInherit Class WebResponse _ Inherits MarshalByRefObject _ Implements ISerializable, IDisposable
[SerializableAttribute] public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable
[SerializableAttribute] public ref class WebResponse abstract : public MarshalByRefObject, ISerializable, IDisposable
[<AbstractClass>] [<SerializableAttribute>] type WebResponse = class inherit MarshalByRefObject interface ISerializable interface IDisposable end
The WebResponse type exposes the following members.
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.
The WebResponse class contains new members when it is used in a Portable Class Library project. For more information, see API Differences in Portable Class Library.
When you inherit from WebResponse, you must override the following members: ContentLength, ContentType, GetResponseStream, ResponseUri, and Headers.
The following example creates a WebResponse instance from a WebRequest.
' 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()
// 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();
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2