Windows.Web.Http.HttpClient.GetAsync

December 16, 2020 ยท View on GitHub

-description

Send 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.

-parameters

-param uri

The Uri to which the request is to be sent.

-returns

The object representing the asynchronous operation.

-remarks

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

For sample code in C#/VB/C++ and XAML that shows how to use HttpClient and GetAsync(Uri) to connect to an HTTP server and send a GET request, see HttpClient.

For sample code in JavaScript and HTML that shows how to use HttpClient and GetAsync(Uri) to connect to an HTTP server and send a GET request, see Connecting to an HTTP server using Windows.Web.Http.

Below are the exceptions that this function throws.

COMException

Thrown when a feature-specific HRESULT is returned from a method call.

This is the most common exception that is thrown by networking methods. An app should use the HRESULT from the exception to determine the cause of the error.

AccessDeniedException

Thrown when access is denied to a resource or feature. This exception occurs when an app doesn't have the required network capabilities set in the app manifest for the network operation requested.

InvalidArgumentException

Thrown when one of the arguments that are provided to a method is not valid.

If user-supplied input caused this exception, an app could inform the user and request new input.

ObjectDisposedException

Thrown when an operation is performed on a disposed object.

OutOfMemoryException

Thrown when insufficient memory is available to complete the operation.

-examples

-see-also

Connecting to an HTTP server using Windows.Web.Http, Handling exceptions in network apps, GetAsync(Uri, HttpCompletionOption), IAsyncOperationWithProgress, HttpResponseMessage, HttpProgress, System.Uri, Windows.Foundation.Uri, Windows.Web.Http, HttpClient