WebResponse Class
This page is specific to:.NET Framework Version:1.12.03.03.5Silverlight 34.0
.NET Framework Class Library
WebResponse Class

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

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

'Usage

Dim instance As WebResponse

'Declaration

<SerializableAttribute> _
Public MustInherit Class WebResponse _
    Inherits MarshalByRefObject _
    Implements ISerializable, IDisposable
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.

Examples

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(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();

Inheritance Hierarchy

System..::.Object
  System..::.MarshalByRefObject
    System.Net..::.WebResponse
      System.IO.Packaging..::.PackWebResponse
      System.Net..::.FileWebResponse
      System.Net..::.FtpWebResponse
      System.Net..::.HttpWebResponse
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.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View