Begins an asynchronous request for a System.IO.Stream object to use to write data.
- The AsyncCallback delegate.
- The state object for this request.
An IAsyncResult that references the asynchronous request.
Type Reason InvalidOperationException
The stream is being used by a previous call to HttpWebRequest.BeginGetRequestStream(AsyncCallback, object) .
No writeable stream is available.
The HttpWebRequest.ContentLength property of the current instance is not set.
The HttpWebRequest.Method property of the current instance is "GET" or "HEAD".
HttpWebRequest.Abort was previously called.
An error occurred while processing the request.
The HttpWebRequest.BeginGetRequestStream(AsyncCallback, object) method starts an asynchronous request for a stream used to send data for the System.Net.HttpWebRequest. The asynchronous callback method uses the HttpWebRequest.EndGetRequestStream(IAsyncResult) method to return the actual stream.
The HttpWebRequest.BeginGetRequestStream(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>].