System.Net.HttpWebResponse Class

Provides an HTTP-specific implementation of the System.Net.WebResponse class.

See Also: HttpWebResponse Members

Syntax

public class HttpWebResponse : WebResponse, IDisposable, System.Runtime.Serialization.ISerializable

Remarks

This class contains support for HTTP-specific uses of the properties and methods of the System.Net.WebResponse class. The System.Net.HttpWebResponse class is used to build HTTP stand-alone client applications that send HTTP requests and receive HTTP responses.

Note:

Do not confuse System.Net.HttpWebResponse with the System.Web.HttpResponse class that is used in ASP.NET applications and whose methods and properties are exposed through ASP.NET's intrinsic Response object.

You should never directly create an instance of the System.Net.HttpWebResponse class. Instead, use the instance returned by a call to HttpWebRequest.GetResponse. You must call either the System.IO.Stream.Close or the HttpWebResponse.Close method to close the response and release the connection for reuse. It is not necessary to call both System.IO.Stream.Close and HttpWebResponse.Close, but doing so does not cause an error.

Common header information returned from the Internet resource is exposed as properties of the class. See the following table for a complete list. Other headers can be read from the HttpWebResponse.Headers property as name/value pairs.

The following table shows the common HTTP headers that are available through properties of the System.Net.HttpWebResponse class.

Content-Encoding

HttpWebResponse.ContentEncoding

Content-Length

HttpWebResponse.ContentLength

Content-Type

HttpWebResponse.ContentType

Last-Modified

HttpWebResponse.LastModified

Server

HttpWebResponse.Server

The contents of the response from the Internet resource are returned as a System.IO.Stream by calling the HttpWebResponse.GetResponseStream method.

Thread Safety

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

Requirements

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