Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata