System.Net.HttpWebRequest.EndGetRequestStream Method

Ends an asynchronous request for a System.IO.Stream object to use to write data.

Syntax

public override System.IO.Stream EndGetRequestStream (IAsyncResult asyncResult)

Parameters

asyncResult
The pending request for a stream.

Returns

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

Exceptions

TypeReason
ArgumentNullException asyncResult is null.
ArgumentException asyncResult was not returned by the current instance from a call to WebRequest.BeginGetRequestStream(AsyncCallback, object).
InvalidOperationException

This method was called previously using asyncResult.

-or-

No stream is available.

System.Net.WebException

HttpWebRequest.Abort was previously called.

-or-

An error occurred while processing the request.

Remarks

The HttpWebRequest.EndGetRequestStream(IAsyncResult) method completes an asynchronous request for a stream that was started by the HttpWebRequest.BeginGetRequestStream(AsyncCallback, object) method. After the System.IO.Stream object has been returned, you can send data with the System.Net.HttpWebRequest by using the System.IO.Stream.Write(Byte[], int, int) method.

Note:

You must set the value of the HttpWebRequest.ContentLength property before writing data to the stream.

Note:

You must call the System.IO.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.

Note:

This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0