BeginGetRequestStream Method
Collapse the table of content
Expand the table of content

HttpWebRequest.BeginGetRequestStream Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Begins an asynchronous request for a Stream object to use to write data.

Namespace:  System.Net
Assembly:  System.Net (in System.Net.dll)

public override IAsyncResult BeginGetRequestStream(
	AsyncCallback callback,
	Object state


Type: System.AsyncCallback
The AsyncCallback delegate.
Type: System.Object
The state object for this request.

Return Value

Type: System.IAsyncResult
An IAsyncResult that references the asynchronous request.


The Method property is GET


The ContentLength property was set to a value that does not match the size of the provided request body.


The stream is being used by a previous call to BeginGetRequestStream


The thread pool is running out of threads.


This method is not implemented.


The request cache validator indicated that the response for this request can be served from the cache; however, requests that write data must not use the cache. This exception can occur if you are using a custom cache validator that is incorrectly implemented.


Abort was previously called.


In a .NET Framework application, a request stream with zero content length was not obtained and closed correctly.

The BeginGetRequestStream method starts an asynchronous request for a stream used to send data for the HttpWebRequest. The asynchronous callback method uses the EndGetRequestStream method to return the actual stream.

You must use the BeginGetResponse method to retrieve the response. The IAsyncResult returned by the BeginGetResponse method does not support the AsyncWaitHandle property. If an application tries to access the AsyncWaitHandle property, a NotSupportedException is thrown.

If AllowWriteStreamBuffering is false, the ContentLength property must be used to set the correct value of the Content-Length header before calling the BeginGetRequestStream method.

The AllowWriteStreamBuffering property affects when the callback from BeginGetRequestStream method is called. When the AllowWriteStreamBuffering property is true, the callback is raised immediately before any data is sent. When the AllowWriteStreamBuffering property is false, the callback is raised only after the headers are sent and then all writes to the stream are immediately sent to the server.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft