System.Net.WebRequest.EndGetRequestStream Method

When overridden in a descendant class, returns a System.IO.Stream for writing data to the Internet resource.

Syntax

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

Parameters

asyncResult
An IAsyncResult that references a pending request for a stream.

Returns

A System.IO.Stream to write data to.

Exceptions

TypeReason
NotSupportedExceptionThis method is not overridden in the derived class.
ArgumentException asyncResult was not returned by a call to WebRequest.BeginGetRequestStream(AsyncCallback, object).
ArgumentNullException asyncResult is a null reference.
InvalidOperationException

This method was called previously using asyncResult.

-or-

No stream is available.

System.Net.WebExceptionAn error occurred while processing the request.

Remarks

The WebRequest.EndGetRequestStream(IAsyncResult) method completes an asynchronous stream request that was started by the WebRequest.BeginGetRequestStream(AsyncCallback, object) method.

Note:

To avoid timing issues with garbage collection, be sure to close the response stream by calling the System.IO.Stream.Close method on the stream returned by WebResponse.GetResponseStream after calling WebRequest.EndGetResponse(IAsyncResult).

Note:

The System.Net.WebRequest class is an abstract class. The actual behavior of System.Net.WebRequest instances at run time is determined by the descendant class returned by the WebRequest.Create(Uri) method. For more information about default values and exceptions, see the documentation for the descendant classes, such as System.Net.HttpWebRequest and System.Net.FileWebRequest.

Requirements

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