HttpClient.GetStringAsync Method

Definition

Send a GET request to the specified Uri and return the response body as a string in an asynchronous operation.

Overloads

GetStringAsync(String)

Send a GET request to the specified Uri and return the response body as a string in an asynchronous operation.

GetStringAsync(Uri)

Send a GET request to the specified Uri and return the response body as a string in an asynchronous operation.

Remarks

This operation will not block.

GetStringAsync(String)

Send a GET request to the specified Uri and return the response body as a string in an asynchronous operation.

public System.Threading.Tasks.Task<string> GetStringAsync (string requestUri);
Parameters
requestUri
String

The Uri the request is sent to.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri is null.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the whole response body is read.

GetStringAsync(Uri)

Send a GET request to the specified Uri and return the response body as a string in an asynchronous operation.

public System.Threading.Tasks.Task<string> GetStringAsync (Uri requestUri);
Parameters
requestUri
Uri

The Uri the request is sent to.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri is null.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the whole response body is read.

Applies to