Export (0) Print
Expand All
1 out of 8 rated this helpful - Rate this topic

WebResponse Class

Provides a response from a Uniform Resource Identifier (URI). This is an abstract class.

Namespace:  System.Net
Assembly:  System (in System.dll)
[SerializableAttribute]
public abstract class WebResponse : MarshalByRefObject, 
	ISerializable, IDisposable

The WebResponse type exposes the following members.

  NameDescription
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsWebResponse()Initializes a new instance of the WebResponse class.
Protected methodWebResponse(SerializationInfo, StreamingContext)Initializes a new instance of the WebResponse class from the specified instances of the SerializationInfo and StreamingContext classes.
Top
  NameDescription
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContentLengthWhen overridden in a descendant class, gets or sets the content length of data being received.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContentTypeWhen overridden in a derived class, gets or sets the content type of the data being received.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsHeadersWhen overridden in a derived class, gets a collection of header name-value pairs associated with this request.
Public propertyIsFromCacheGets a Boolean value that indicates whether this response was obtained from the cache.
Public propertyIsMutuallyAuthenticatedGets a Boolean value that indicates whether mutual authentication occurred.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsResponseUriWhen overridden in a derived class, gets the URI of the Internet resource that actually responded to the request.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsSupportsHeadersGets a value that indicates if headers are supported.
Top
  NameDescription
Public methodCloseWhen overridden by a descendant class, closes the response stream.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsDispose()Releases the unmanaged resources used by the WebResponse object.
Protected methodSupported in .NET for Windows Store appsDispose(Boolean)Releases the unmanaged resources used by the WebResponse object, and optionally disposes of the managed resources.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodGetObjectDataInfrastructure. Populates a SerializationInfo with the data that is needed to serialize the target object.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetResponseStreamWhen overridden in a descendant class, returns the data stream from the Internet resource.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Explicit interface implemetationPrivate methodIDisposable.DisposeInfrastructure. When overridden in a derived class, releases all resources used by the WebResponse.
Explicit interface implemetationPrivate methodISerializable.GetObjectDataInfrastructure. Populates a SerializationInfo instance with the data that is needed to serialize WebResponse.
Top

The WebResponse class is the abstract base class from which protocol-specific response classes are derived. Applications can participate in request and response transactions in a protocol-agnostic manner using instances of the WebResponse class while protocol-specific classes derived from WebResponse carry out the details of the request.

Client applications do not create WebResponse objects directly; they are created by calling the GetResponse method on a WebRequest instance.

Notes to Inheritors

When you inherit from WebResponse, you must override the following members: ContentLength, ContentType, GetResponseStream, ResponseUri, and Headers.

The following example creates a WebResponse instance from a WebRequest.

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.