O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required