See Also: WebResponse Members
System.Object
System.MarshalByRefObject
System.Net.WebResponse
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
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:
- WebResponse.ContentLength: Gets or sets the content length of the data being received.
- WebResponse.ContentType: Gets or sets the media type of the data being received.
- WebResponse.GetResponseStream: Returns a System.IO.Stream that contains data from the current host.
- WebResponse.ResponseUri: Gets a Uri containing the URI of the resource associated with the current instance.
- WebResponse.Headers: Gets or sets the collection of header name/value pairs associated with the current instance.
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 .
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(); } }
Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.x.x, 1.0.5000.0, 2.0.0.0