Provides an HTTP-specific implementation of the WebRequest class.
Assembly: System (in System.dll)
Thetype exposes the following members.
|HttpWebRequest()||Obsolete. Initializes a new instance of the class.|
|HttpWebRequest(SerializationInfo, StreamingContext)||Obsolete. Initializes a new instance of the class from the specified instances of the SerializationInfo and StreamingContext classes.|
|Accept||Gets or sets the value of the Accept HTTP header.|
|Address||Gets the Uniform Resource Identifier (URI) of the Internet resource that actually responds to the request.|
|AllowAutoRedirect||Gets or sets a value that indicates whether the request should follow redirection responses.|
|AllowReadStreamBuffering||Gets or sets a value that indicates whether to buffer the received from the Internet resource.|
|AllowWriteStreamBuffering||Gets or sets a value that indicates whether to buffer the data sent to the Internet resource.|
|AuthenticationLevel||Gets or sets values indicating the level of authentication and impersonation used for this request. (Inherited from WebRequest.)|
|AutomaticDecompression||Gets or sets the type of decompression that is used.|
|CachePolicy||Gets or sets the cache policy for this request. (Inherited from WebRequest.)|
|ClientCertificates||Gets or sets the collection of security certificates that are associated with this request.|
|Connection||Gets or sets the value of the Connection HTTP header.|
|ConnectionGroupName||Gets or sets the name of the connection group for the request. (Overrides WebRequest.ConnectionGroupName.)|
|ContentLength||Gets or sets the Content-length HTTP header. (Overrides WebRequest.ContentLength.)|
|ContentType||Gets or sets the value of the Content-type HTTP header. (Overrides WebRequest.ContentType.)|
|ContinueDelegate||Gets or sets the delegate method called when an HTTP 100-continue response is received from the Internet resource.|
|ContinueTimeout||Gets or sets a timeout, in milliseconds, to wait until the 100-Continue is received from the server.|
|CookieContainer||Gets or sets the cookies associated with the request.|
|CreatorInstance||Obsolete. When overridden in a descendant class, gets the factory object derived from the IWebRequestCreate class used to create the WebRequest instantiated for making the request to the specified URI. (Inherited from WebRequest.)|
|Credentials||Gets or sets authentication information for the request. (Overrides WebRequest.Credentials.)|
|Date||Get or set the Date HTTP header value to use in an HTTP request.|
|DefaultCachePolicy||Gets or sets the default cache policy for this request.|
|DefaultMaximumErrorResponseLength||Gets or sets the default maximum length of an HTTP error response.|
|DefaultMaximumResponseHeadersLength||Gets or sets the default for the MaximumResponseHeadersLength property.|
|Expect||Gets or sets the value of the Expect HTTP header.|
|HaveResponse||Gets a value that indicates whether a response has been received from an Internet resource.|
|Headers||Specifies a collection of the name/value pairs that make up the HTTP headers. (Overrides WebRequest.Headers.)|
|Host||Get or set the Host header value to use in an HTTP request independent from the request URI.|
|IfModifiedSince||Gets or sets the value of the If-Modified-Since HTTP header.|
|ImpersonationLevel||Gets or sets the impersonation level for the current request. (Inherited from WebRequest.)|
|KeepAlive||Gets or sets a value that indicates whether to make a persistent connection to the Internet resource.|
|MaximumAutomaticRedirections||Gets or sets the maximum number of redirects that the request follows.|
|MaximumResponseHeadersLength||Gets or sets the maximum allowed length of the response headers.|
|MediaType||Gets or sets the media type of the request.|
|Method||Gets or sets the method for the request. (Overrides WebRequest.Method.)|
|Pipelined||Gets or sets a value that indicates whether to pipeline the request to the Internet resource.|
|PreAuthenticate||Gets or sets a value that indicates whether to send an Authorization header with the request. (Overrides WebRequest.PreAuthenticate.)|
|ProtocolVersion||Gets or sets the version of HTTP to use for the request.|
|Proxy||Gets or sets proxy information for the request. (Overrides WebRequest.Proxy.)|
|ReadWriteTimeout||Gets or sets a time-out in milliseconds when writing to or reading from a stream.|
|Referer||Gets or sets the value of the Referer HTTP header.|
|RequestUri||Gets the original Uniform Resource Identifier (URI) of the request. (Overrides WebRequest.RequestUri.)|
|SendChunked||Gets or sets a value that indicates whether to send data in segments to the Internet resource.|
|ServerCertificateValidationCallback||Gets or sets a callback function to validate the server certificate.|
|ServicePoint||Gets the service point to use for the request.|
|SupportsCookieContainer||Gets a value that indicates whether the request provides support for a CookieContainer.|
|Timeout||Gets or sets the time-out value in milliseconds for the GetResponse and GetRequestStream methods. (Overrides WebRequest.Timeout.)|
|TransferEncoding||Gets or sets the value of the Transfer-encoding HTTP header.|
|UnsafeAuthenticatedConnectionSharing||Gets or sets a value that indicates whether to allow high-speed NTLM-authenticated connection sharing.|
|UseDefaultCredentials||Gets or sets a Boolean value that controls whether default credentials are sent with requests. (Overrides WebRequest.UseDefaultCredentials.)|
|UserAgent||Gets or sets the value of the User-agent HTTP header.|
|Abort||Cancels a request to an Internet resource. (Overrides WebRequest.Abort().)|
|AddRange(Int32)||Adds a byte range header to a request for a specific range from the beginning or end of the requested data.|
|AddRange(Int64)||Adds a byte range header to a request for a specific range from the beginning or end of the requested data.|
|AddRange(Int32, Int32)||Adds a byte range header to the request for a specified range.|
|AddRange(Int64, Int64)||Adds a byte range header to the request for a specified range.|
|AddRange(String, Int32)||Adds a Range header to a request for a specific range from the beginning or end of the requested data.|
|AddRange(String, Int64)||Adds a Range header to a request for a specific range from the beginning or end of the requested data.|
|AddRange(String, Int32, Int32)||Adds a range header to a request for a specified range.|
|AddRange(String, Int64, Int64)||Adds a range header to a request for a specified range.|
|BeginGetRequestStream||Begins an asynchronous request for a Stream object to use to write data. (Overrides WebRequest.BeginGetRequestStream(AsyncCallback, Object).)|
|BeginGetResponse||Begins an asynchronous request to an Internet resource. (Overrides WebRequest.BeginGetResponse(AsyncCallback, Object).)|
|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(IAsyncResult)||Ends an asynchronous request for a Stream object to use to write data. (Overrides WebRequest.EndGetRequestStream(IAsyncResult).)|
|EndGetRequestStream(IAsyncResult, TransportContext)||Ends an asynchronous request for a Stream object to use to write data and outputs the TransportContext associated with the stream.|
|EndGetResponse||Ends an asynchronous request to an Internet resource. (Overrides WebRequest.EndGetResponse(IAsyncResult).)|
|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 required to serialize the target object. (Overrides WebRequest.GetObjectData(SerializationInfo, StreamingContext).)|
|GetRequestStream()||Gets a Stream object to use to write request data. (Overrides WebRequest.GetRequestStream().)|
|GetRequestStream(TransportContext)||Gets a Stream object to use to write request data and outputs the TransportContext associated with the stream.|
|GetRequestStreamAsync||When overridden in a descendant class, returns a Stream for writing data to the Internet resource as an asynchronous operation. (Inherited from WebRequest.)|
|GetResponse||Returns a response from an Internet resource. (Overrides WebRequest.GetResponse().)|
|GetResponseAsync||When overridden in a descendant class, returns a response to an Internet request as an asynchronous operation. (Inherited from WebRequest.)|
|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.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
The class provides support for the properties and methods defined in WebRequest and for additional properties and methods that enable the user to interact directly with servers using HTTP.
Do not use the HttpWebRequest constructor. Use the WebRequest.Create method to initialize new objects. If the scheme for the Uniform Resource Identifier (URI) is http:// or https://, Create returns an object.
The GetResponse method makes a synchronous request to the resource specified in the RequestUri property and returns an HttpWebResponse that contains the response. You can make an asynchronous request to the resource using the BeginGetResponse and EndGetResponse methods.
When you want to send data to the resource, the GetRequestStream method returns a Stream object to use to send data. The BeginGetRequestStream and EndGetRequestStream methods provide asynchronous access to the send data stream.
For client authentication with , the client certificate must be installed in the My certificate store of the current user.
The class throws a WebException when errors occur while accessing a resource. The WebException.Status property contains a WebExceptionStatus value that indicates the source of the error. When WebException.Status is WebExceptionStatus.ProtocolError, the Response property contains the HttpWebResponse received from the resource.
exposes common HTTP header values sent to the Internet resource as properties, set by methods, or set by the system; the following table contains a complete list. You can set other headers in the Headers property as name/value pairs. Note that servers and caches may change or add headers during the request.
The following table lists the HTTP headers that are set either by properties or methods or the system.
Set by the Accept property.
Set by the ContentLength property.
Set by the ContentType property.
Set by the Expect property.
Set by the system to current date.
Set by the system to current host information.
Set by the IfModifiedSince property.
Set by the AddRange method.
Set by the Referer property.
Set by the UserAgent property.
is registered automatically. You do not need to call the RegisterPrefix method to register before using URIs beginning with http:// or https://.
The local computer or application config file may specify that a default proxy be used. If the Proxy property is specified, then the proxy settings from the Proxy property override the local computer or application config file and the instance will use the proxy settings specified. If no proxy is specified in a config file and the Proxy property is unspecified, the class uses the proxy settings inherited from Internet Explorer on the local computer. If there are no proxy settings in Internet Explorer, the request is sent directly to the server.
The class parses a proxy bypass list with wildcard characters inherited from Internet Explorer differently than the bypass list is parsed directly by Internet Explorer. For example, the class will parse a bypass list of "nt*" from Internet Explorer as a regular expression of "nt.$". This differs from the native behavior of Internet Explorer. So a URL of "http://intxxxxx" would bypass the proxy using the class, but would not bypass the proxy using Internet Explorer.
The Framework caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. When attempting to reuse an SSL session, the Framework uses the first element of ClientCertificates (if there is one), or tries to reuse an anonymous sessions if ClientCertificates is empty.
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.