HttpClient.GetAsync HttpClient.GetAsync HttpClient.GetAsync HttpClient.GetAsync HttpClient.GetAsync Method

Definition

Overloads

GetAsync(Uri) GetAsync(Uri) GetAsync(Uri) GetAsync(Uri) GetAsync(Uri)

Send a GET request to the specified Uri as an asynchronous operation.

GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption)

Send a GET request to the specified Uri with an HTTP completion option as an asynchronous operation.

GetAsync(Uri) GetAsync(Uri) GetAsync(Uri) GetAsync(Uri) GetAsync(Uri)

Send a GET request to the specified Uri as an asynchronous operation.

public : IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> GetAsync(Uri uri)
IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> GetAsync(Uri uri) const;
public IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> GetAsync(Uri uri)
Public Function GetAsync(uri As Uri) As IAsyncOperationWithProgress(Of HttpResponseMessageHttpProgress)
Windows.Web.Http.HttpClient.getAsync(uri).done( /* Your success and error handlers */ );
Parameters
uri
Uri Uri Uri

The Uri to which the request is to be sent.

Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(HttpResponseMessage, HttpProgress) object will complete 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.

See Also

GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption) GetAsync(Uri, HttpCompletionOption)

Send a GET request to the specified Uri with an HTTP completion option as an asynchronous operation.

public : IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> GetAsync(Uri uri, HttpCompletionOption completionOption)
IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> GetAsync(Uri uri, HttpCompletionOption completionOption) const;
public IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> GetAsync(Uri uri, HttpCompletionOption completionOption)
Public Function GetAsync(uri As Uri, completionOption As HttpCompletionOption) As IAsyncOperationWithProgress(Of HttpResponseMessageHttpProgress)
Windows.Web.Http.HttpClient.getAsync(uri, completionOption).done( /* Your success and error handlers */ );
Parameters
uri
Uri Uri Uri

The Uri the request is sent to.

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption

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

Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(HttpResponseMessage, HttpProgress) object will complete based on the completionOption parameter after part or all of the response (including content) is read.

Below are the exceptions that this content 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.

See Also