WebClient.DownloadStringTaskAsync Method

Definition

Downloads the resource as a String from the URI specified as an asynchronous operation using a task object. These methods do not block the calling thread.

Overloads

DownloadStringTaskAsync(String)

Downloads the resource as a String from the URI specified as an asynchronous operation using a task object.

DownloadStringTaskAsync(Uri)

Downloads the resource as a String from the URI specified as an asynchronous operation using a task object.

DownloadStringTaskAsync(String)

Downloads the resource as a String from the URI specified as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<System::String ^> ^ DownloadStringTaskAsync(System::String ^ address);
public System.Threading.Tasks.Task<string> DownloadStringTaskAsync (string address);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<string> DownloadStringTaskAsync (string address);
member this.DownloadStringTaskAsync : string -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.DownloadStringTaskAsync : string -> System.Threading.Tasks.Task<string>
Public Function DownloadStringTaskAsync (address As String) As Task(Of String)

Parameters

address
String

The URI of the resource to download.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns a Byte array containing the downloaded resource.

Attributes

Exceptions

The address parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

An error occurred while downloading the resource.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the data resource has been downloaded. The resource is downloaded asynchronously using thread resources that are automatically allocated from the thread pool.

After downloading the resource, this method uses the encoding specified in the Encoding property to convert the resource to a String. This method does not block the calling thread while downloading the resource.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

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

This method uses the RETR command to download an FTP resource. For an HTTP resource, the GET method is used.

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

Applies to

DownloadStringTaskAsync(Uri)

Downloads the resource as a String from the URI specified as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<System::String ^> ^ DownloadStringTaskAsync(Uri ^ address);
public System.Threading.Tasks.Task<string> DownloadStringTaskAsync (Uri address);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<string> DownloadStringTaskAsync (Uri address);
member this.DownloadStringTaskAsync : Uri -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.DownloadStringTaskAsync : Uri -> System.Threading.Tasks.Task<string>
Public Function DownloadStringTaskAsync (address As Uri) As Task(Of String)

Parameters

address
Uri

The URI of the resource to download.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns a Byte array containing the downloaded resource.

Attributes

Exceptions

The address parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

An error occurred while downloading the resource.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the data resource has been downloaded. The resource is downloaded asynchronously using thread resources that are automatically allocated from the thread pool.

After downloading the resource, this method uses the encoding specified in the Encoding property to convert the resource to a String. This method does not block the calling thread while downloading the resource.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

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

This method uses the RETR command to download an FTP resource. For an HTTP resource, the GET method is used.

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

Applies to