HttpClient.TryGetAsync Method

Definition

Overloads

TryGetAsync(Uri)

Sends a GET request to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

TryGetAsync(Uri, HttpCompletionOption)

Sends a GET request to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

TryGetAsync(Uri)

Sends a GET request to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

C#
[Windows.Foundation.Metadata.Overload("TryGetAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<HttpRequestResult,HttpProgress> TryGetAsync(System.Uri uri);

Parameters

uri
Uri

The Uri the request is sent to.

Returns

The object representing the asynchronous operation.

Attributes

Windows requirements

Device family
Windows 10, version 1903 (introduced in 10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v8.0)

Remarks

This operation will not throw an exception on network errors. Instead you should examine the HttpRequestResult to learn about the original HTTP request, the resulting HTTP response (if any) and error (if any). This operation will throw when the operation is canceled.

This operation will not block. The returned IAsyncOperationWithProgress (of HttpRequestResult and HttpProgress) completes after the whole response (including content) is read.

See also

Applies to

WinRT Build 26100 and other versions
Product Versions
WinRT Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

TryGetAsync(Uri, HttpCompletionOption)

Sends a GET request to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

C#
[Windows.Foundation.Metadata.Overload("TryGetAsync2")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<HttpRequestResult,HttpProgress> TryGetAsync(System.Uri uri, HttpCompletionOption completionOption);

Parameters

uri
Uri

The Uri the request is sent to.

completionOption
HttpCompletionOption

An HTTP completion option value that indicates when the operation should be considered completed.

Returns

The object representing the asynchronous operation.

Attributes

Windows requirements

Device family
Windows 10, version 1903 (introduced in 10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v8.0)

Remarks

This operation will not throw an exception on network errors. Instead you should examine the HttpRequestResult to learn about the original HTTP request, the resulting HTTP response (if any) and error (if any). This operation will throw when the operation is canceled.

This operation will not block. The returned IAsyncOperationWithProgress (of HttpRequestResult and HttpProgress) completes based on the completionOption parameter after part or all of the response (including content) is read.

See also

Applies to

WinRT Build 26100 and other versions
Product Versions
WinRT Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100