Makes a request to a Uniform Resource Identifier (URI). This is an abstract class.
Assembly: System (in System.dll)
Thetype exposes the following members.
|AuthenticationLevel||Gets or sets values indicating the level of authentication and impersonation used for this request.|
|CachePolicy||Gets or sets the cache policy for this request.|
|ConnectionGroupName||When overridden in a descendant class, gets or sets the name of the connection group for the request.|
|ContentLength||When overridden in a descendant class, gets or sets the content length of the request data being sent.|
|ContentType||When overridden in a descendant class, gets or sets the content type of the request data being sent.|
|CreatorInstance||Obsolete. When overridden in a descendant class, gets the factory object derived from the IWebRequestCreate class used to create the instantiated for making the request to the specified URI.|
|Credentials||When overridden in a descendant class, gets or sets the network credentials used for authenticating the request with the Internet resource.|
|DefaultCachePolicy||Gets or sets the default cache policy for this request.|
|DefaultWebProxy||Gets or sets the global HTTP proxy.|
|Headers||When overridden in a descendant class, gets or sets the collection of header name/value pairs associated with the request.|
|ImpersonationLevel||Gets or sets the impersonation level for the current request.|
|Method||When overridden in a descendant class, gets or sets the protocol method to use in this request.|
|PreAuthenticate||When overridden in a descendant class, indicates whether to pre-authenticate the request.|
|Proxy||When overridden in a descendant class, gets or sets the network proxy to use to access this Internet resource.|
|RequestUri||When overridden in a descendant class, gets the URI of the Internet resource associated with the request.|
|Timeout||Gets or sets the length of time, in milliseconds, before the request times out.|
|UseDefaultCredentials||When overridden in a descendant class, gets or sets a Boolean value that controls whether DefaultCredentials are sent with requests.|
|Abort||Aborts the Request|
|BeginGetRequestStream||When overridden in a descendant class, provides an asynchronous version of the GetRequestStream method.|
|BeginGetResponse||When overridden in a descendant class, begins an asynchronous request for an Internet resource.|
|Create(String)||Initializes a new instance for the specified URI scheme.|
|Create(Uri)||Initializes a new instance for the specified URI scheme.|
|CreateDefault||Initializes a new instance for the specified URI scheme.|
|CreateHttp(String)||Initializes a new HttpWebRequest instance for the specified URI string.|
|CreateHttp(Uri)||Initializes a new HttpWebRequest instance for the specified URI.|
|CreateObjRef||Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)|
|EndGetRequestStream||When overridden in a descendant class, returns a Stream for writing data to the Internet resource.|
|EndGetResponse||When overridden in a descendant class, returns a WebResponse.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetLifetimeService||Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)|
|GetObjectData||Infrastructure. Populates a SerializationInfo with the data needed to serialize the target object.|
|GetRequestStream||When overridden in a descendant class, returns a Stream for writing data to the Internet resource.|
|GetRequestStreamAsync||When overridden in a descendant class, returns a Stream for writing data to the Internet resource as an asynchronous operation.|
|GetResponse||When overridden in a descendant class, returns a response to an Internet request.|
|GetResponseAsync||When overridden in a descendant class, returns a response to an Internet request as an asynchronous operation.|
|GetSystemWebProxy||Returns a proxy configured with the Internet Explorer settings of the currently impersonated user.|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|InitializeLifetimeService||Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)|
|MemberwiseClone()||Creates a shallow copy of the current Object. (Inherited from Object.)|
|MemberwiseClone(Boolean)||Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)|
|RegisterPortableWebRequestCreator||Obsolete. Register an IWebRequestCreate object.|
|RegisterPrefix||Registers a descendant for the specified URI.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
is the abstract base class for the .NET Framework's request/response model for accessing data from the Internet. An application that uses the request/response model can request data from the Internet in a protocol-agnostic manner, in which the application works with instances of the class while protocol-specific descendant classes carry out the details of the request.
Requests are sent from an application to a particular URI, such as a Web page on a server. The URI determines the proper descendant class to create from a list of descendants registered for the application. descendants are typically registered to handle a specific protocol, such as HTTP or FTP, but can be registered to handle a request to a specific server or path on a server.
The class throws a WebException when errors occur while accessing an Internet resource. The Status property is one of the WebExceptionStatus values that indicates the source of the error. When Status is WebExceptionStatus.ProtocolError, the Response property contains the WebResponse received from the Internet resource.
Because the class is an abstract class, the actual behavior of instances at run time is determined by the descendant class returned by Create method. For more information about default values and exceptions, see the documentation for the descendant classes, such as HttpWebRequest and FileWebRequest.
Use the Create method to initialize new instances. Do not use the constructor.
If the application that creates the WebRequest object runs with the credentials of a Normal user, the application will not be able to access certificates installed in the local machine store unless permission has been explicitly given to the user to do so.
When you inherit from , you must override the following members: Method, RequestUri, Headers, ContentLength, ContentType, Credentials, PreAuthenticate, GetRequestStream, BeginGetRequestStream, EndGetRequestStream, GetResponse, BeginGetResponse, and EndGetResponse. In addition, you must provide an implementation of the IWebRequestCreate interface, which defines the Create method used when you call Create. You must register the class that implements the IWebRequestCreate interface, using the RegisterPrefix method or the configuration file.
.NET FrameworkSupported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported 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.