Name

WebResponse

Synopsis

This class represents a response received from a WebRequest. A response consists of headers (stored as key/value pairs in the Headers property) and a response body. You can obtain the response body as a System.IO.Stream using the GetResponseStream() method.

When you are finished with the response, call its Close() method; this releases any open resources still held by the WebResponse without having to wait for garbage collection to do so (which could take longer than desired).

public abstract class WebResponse : MarshalByRefObject,  
                                                   System.Runtime.Serialization.ISerializable, IDisposable {
// Protected Constructors
   protected method WebResponse();  
   protected method WebResponse(
        System.Runtime.Serialization.SerializationInfo serializationInfo, 
        System.Runtime.Serialization.StreamingContext streamingContext);  
// Public Instance Properties
   public virtual field long ContentLength{set; get; } 
   public virtual field string ContentType{set; get; } 
   public virtual field WebHeaderCollection Headers{get; } 
   public virtual field Uri ResponseUri{get; } 
// Public Instance Methods
   public virtual method void Close();  
   public virtual method Stream GetResponseStream();  
}

Hierarchy

System.ObjectSystem.MarshalByRefObjectWebResponse(System.Runtime.Serialization.ISerializable, System.IDisposable)

Subclasses

FileWebResponse, HttpWebResponse

Returned By

WebException.Response, WebRequest.{EndGetResponse(), GetResponse()}

Passed To

WebException.WebException()

Get C# in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.