This documentation is archived and is not being maintained.

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.


[Visual Basic]
MustInherit Public Class WebResponse
   Inherits MarshalByRefObject
   Implements ISerializable, IDisposable
public abstract class WebResponse : MarshalByRefObject,
   ISerializable, IDisposable
public __gc __abstract class WebResponse : public
   MarshalByRefObject, ISerializable, IDisposable
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.


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.


[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("")

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

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

// Initialize the WebRequest.
WebRequest myRequest = WebRequest.Create("");

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

// Code to use the WebResponse goes here.

// Close the response to free resources.

// Initialize the WebRequest.
WebRequest* myRequest = WebRequest::Create(S"");

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

// Code to use the WebResponse goes here.

// Close the response to free resources.

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


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)

See Also

WebResponse Members | System.Net Namespace