WebResponse Class
Provides a response from a Uniform Resource Identifier (URI). This is an abstract (MustInherit in Visual Basic) class.
For a list of all members of this type, see WebResponse Members.
System.Object
System.MarshalByRefObject
System.Net.WebResponse
System.Net.FileWebResponse
System.Net.HttpWebResponse
[Visual Basic] <Serializable> MustInherit Public Class WebResponse Inherits MarshalByRefObject Implements ISerializable, IDisposable [C#] [Serializable] public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable [C++] [Serializable] public __gc __abstract class WebResponse : public MarshalByRefObject, ISerializable, IDisposable [JScript] public Serializable abstract class WebResponse extends MarshalByRefObject implements ISerializable, IDisposable
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.
Remarks
The WebResponse class is the abstract (MustInherit in Visual Basic) 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.
Example
[Visual Basic, C#, C++] The following example creates a WebResponse instance from a WebRequest.
[Visual Basic] ' 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() [C#] // 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(); [C++] // Initialize the WebRequest. WebRequest* myRequest = WebRequest::Create(S"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();
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Net
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: System (in System.dll)