Export (0) Print
Expand All

HttpWebRequest.EndGetRequestStream Method (IAsyncResult, TransportContext)

Ends an asynchronous request for a Stream object to use to write data and outputs the TransportContext associated with the stream.

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

member EndGetRequestStream : 
        asyncResult:IAsyncResult * 
        context:TransportContext byref -> Stream


Type: System.IAsyncResult

The pending request for a stream.

Type: System.Net.TransportContext

The TransportContext for the Stream.

Return Value

Type: System.IO.Stream
A Stream to use to write request data.


asyncResult was not returned by the current instance from a call to BeginGetRequestStream.


asyncResult is a null reference (Nothing in Visual Basic).


This method was called previously using asyncResult.


The request did not complete, and no stream is available.


Abort was previously called.


An error occurred while processing the request.

The EndGetRequestStream method completes an asynchronous request for a stream that was started by the BeginGetRequestStream method and outputs the TransportContext associated with the stream. After the Stream object has been returned, you can send data with the HttpWebRequest by using the Stream.Write method.

Some applications that use integrated Windows authentication with extended protection may need to be able to query the transport layer used by HttpWebRequest in order to retrieve the channel binding token (CBT) from the underlying TLS channel. The GetRequestStream method provides access to this information for HTTP methods which have a request body (POST and PUT requests). This is only needed if the application is implementing its own authentication and needs access to the CBT.


If an application needs to set the value of the ContentLength property, then this must be done before retrieving the stream and writing data to it.

Caution noteCaution

You must call the Stream.Close method to close the stream and release the connection for reuse. Failure to close the stream causes your application to run out of connections.


This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, 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.

© 2014 Microsoft