Mono Class Library: System.Net Namespace

System.Net.WebResponse Class

Represents a response received from a Uniform Resource Identifier (URI). [Edit]

See Also: WebResponse Members

System.Object
     System.MarshalByRefObject
          System.Net.WebResponse

public abstract class WebResponse : MarshalByRefObject, IDisposable, System.Runtime.Serialization.ISerializable

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

System.Net.WebResponse is the base class from which protocol-specific response classes, such as System.Net.HttpWebResponse , are derived.

Classes that derive from System.Net.WebResponse are required to override the following members in the System.Net.WebResponse class:

Note:

Applications can participate in request/response transactions in a protocol-agnostic manner using instances of the System.Net.WebResponse class while protocol-specific classes derived from System.Net.WebResponse carry out the details of the request.

Applications do not create System.Net.WebResponse objects directly; they are created by calling WebRequest.GetResponse .

[Edit]

Example

The following example creates a System.Net.WebResponse instance from a System.Net.WebRequest .

C# Example
using System;
using System.Net;

public class WebResponseExample {

  public static void Main() {

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

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.x.x, 1.0.5000.0, 2.0.0.0