- The AsyncCallback delegate
- The state object for this request.
An IAsyncResult that references the asynchronous request for a response.
Type Reason InvalidOperationException HttpWebRequest.BeginGetResponse(AsyncCallback, object) or HttpWebRequest.GetResponse was previously called on this instance. System.Net.ProtocolViolationException The HttpWebRequest.ContentLength property of the current instance has not been set. System.Net.WebException HttpWebRequest.Abort was previously called.
The HttpWebRequest.BeginGetResponse(AsyncCallback, object) method starts an asynchronous request for a response from the Internet resource. The asynchronous callback method uses the HttpWebRequest.EndGetResponse(IAsyncResult) method to return the actual System.Net.WebResponse.
A System.Net.ProtocolViolationException is thrown in several cases when the properties set on the System.Net.HttpWebRequest class are conflicting. This exception occurs if an application sets the HttpWebRequest.ContentLength property and the HttpWebRequest.SendChunked property to true, and then sends an HTTP GET request. This exception occurs if an application tries to send chunked to a server that only supports HTTP 1.0 protocol, where this is not supported. This exception occurs if an application tries to send data without setting the HttpWebRequest.ContentLength property or the HttpWebRequest.SendChunked is false when buffering is disabled and on a keepalive connection (the HttpWebRequest.KeepAlive property is true).
The HttpWebRequest.BeginGetResponse(AsyncCallback, object) method requires some synchronous setup tasks to complete (DNS resolution, proxy detection, and TCP socket connection, for example) before this method becomes asynchronous. As a result, this method should never be called on a user interface (UI) thread because it might take considerable time (up to several minutes depending on network settings) to complete the initial synchronous setup tasks before an exception for an error is thrown or the method succeeds.
To learn more about the thread pool, see [<topic://cpconthreadpooling>].
Your application cannot mix synchronous and asynchronous methods for a particular request. If you call the HttpWebRequest.BeginGetRequestStream(AsyncCallback, object) method, you must use the HttpWebRequest.BeginGetResponse(AsyncCallback, object) method to retrieve the response.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].