[Serializable] |
Client applications do not create WebResponse objects directly, they are created by calling the WebRequest.GetResponse method on a WebRequest instance.
// 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();
ContentLength | Read-write When overridden in a descendant class, gets or sets the content length of data being received. |
ContentType | Read-write When overridden in a derived class, gets or sets the content type of the data being received. |
Headers | Read-only When overridden in a derived class, gets a collection of header name-value pairs associated with this request. |
ResponseUri | Read-only When overridden in a derived class, gets the URI of the Internet resource that actually responded to the request. |
Close | When overridden by a descendent class, closes the response stream. |
CreateObjRef (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. |
GetResponseStream | When overridden in a descendant class, returns the data stream from the Internet resource. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
InitializeLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Overloaded:.ctor() Default constructor. This constructor is called by derived class constructors to initialize state in this type.Initializes a new instance of the WebResponse class. |
ctor #2 | Overloaded:.ctor(SerializationInfo serializationInfo, StreamingContext streamingContext) Initializes a new instance of the WebResponse class from the specified instances of the SerializationInfo and StreamingContext classes. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
protected WebResponse(); |
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to access the constructor, when the constructor is not overridden in a descendant class. |
protected WebResponse( |
serializationInfo
streamingContext
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to access the constructor, when the constructor is not overridden in a descendant class. |
public virtual long ContentLength {get; set;}
|
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to get or set the property, when the property is not overridden in a descendant class. |
public virtual string ContentType {get; set;}
|
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to get or set the property, when the property is not overridden in a descendant class. |
public virtual WebHeaderCollection Headers {get;}
|
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to get or set the property, when the property is not overridden in a descendant class. |
public virtual Uri ResponseUri {get;}
|
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to get or set the property, when the property is not overridden in a descendant class. |
public virtual void Close(); |
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to access the method, when the method is not overridden in a descendant class. |
[behaviors: This method is required to free the connection used by the System.IO.Stream returned by a call to System.Net.WebResponse.GetResponseStream.] [default: This method throws System.NotSupportedException.] [overrides: This method is required to be overridden in derived classes to close the response stream and free resources allocated by the current instance.] [usage: Use this method or System.IO.Stream.Close to clean up the resources used by a System.Net.WebResponse.]
requestedType
Exception Type | Condition |
---|---|
RemotingException | This instance is not a valid remoting object. |
~WebResponse(); |
public virtual int GetHashCode(); |
public object GetLifetimeService(); |
public virtual Stream GetResponseStream(); |
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to access the method, when the method is not overridden in a descendant class. |
public Type GetType(); |
public virtual object InitializeLifetimeService(); |
public class MyClass : MarshalByRefObject { public override Object InitializeLifetimeService() { ILease lease = (ILease)base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { lease.InitialLeaseTime = TimeSpan.FromMinutes(1); lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); lease.RenewOnCallTime = TimeSpan.FromSeconds(2); } return lease; } }
protected object MemberwiseClone(); |
public virtual string ToString(); |