Export (0) Print
Expand All

WebClient.DownloadStringAsync Method (Uri, Object)

Downloads the resource at the specified Uri as a string.

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

public void DownloadStringAsync(
	Uri address,
	Object userToken
)

Parameters

address
Type: System.Uri
The location of the resource to be downloaded.
userToken
Type: System.Object
Provides a user-specified identifier for the asynchronous task.

ExceptionCondition
ArgumentNullException

The address parameter is null.

OutOfMemoryException

There is not enough memory to continue the execution of the program.

StackOverflowException

The execution stack overflowed because it contains too many nested method calls.

ThreadAbortException

A call was made to the Thread.Abort method to destroy a thread.

This method retrieves the specified resource using the GET method. The resource is downloaded asynchronously. When the download is completed, the DownloadStringCompleted event is raised. The downloaded string is available in the Result property of the DownloadStringCompletedEventArgs. You cannot call the DownloadStringAsync method again on the same WebClient object, until the first string download operation is completed. Doing this causes an exception.

You can use the CancelAsync method to cancel asynchronous operations that have not completed.

If the BaseAddress property is not an empty string and the address does not contain an absolute URI, the address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data.

Retrieve the userToken as the UserState property of the AsyncCompletedEventArgs passed to the method invoked when the asynchronous operation is completed.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft