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

Definition

以异步操作将 GET 请求发送给指定 URI。 Send a GET request to the specified Uri as an asynchronous operation.

Overloads

GetAsync(String) GetAsync(String) GetAsync(String) GetAsync(String)

以异步操作将 GET 请求发送给指定 URI。 Send a GET request to the specified Uri as an asynchronous operation.

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

以异步操作将 GET 请求发送给指定 URI。 Send a GET request to the specified Uri as an asynchronous operation.

GetAsync(String, HttpCompletionOption) GetAsync(String, HttpCompletionOption) GetAsync(String, HttpCompletionOption) GetAsync(String, HttpCompletionOption)

用以异步操作的 HTTP 完成选项发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option as an asynchronous operation.

GetAsync(String, CancellationToken) GetAsync(String, CancellationToken) GetAsync(String, CancellationToken)

用以异步操作的取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with a cancellation token as an asynchronous operation.

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

用以异步操作的 HTTP 完成选项发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option as an asynchronous operation.

GetAsync(Uri, CancellationToken) GetAsync(Uri, CancellationToken) GetAsync(Uri, CancellationToken)

用以异步操作的取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with a cancellation token as an asynchronous operation.

GetAsync(String, HttpCompletionOption, CancellationToken) GetAsync(String, HttpCompletionOption, CancellationToken) GetAsync(String, HttpCompletionOption, CancellationToken)

用以异步操作的 HTTP 完成选项和取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.

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

用以异步操作的 HTTP 完成选项和取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.

Remarks

不会阻止该操作。The operation will not block.

GetAsync(String) GetAsync(String) GetAsync(String) GetAsync(String)

以异步操作将 GET 请求发送给指定 URI。 Send a GET request to the specified Uri as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(System::String ^ requestUri);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (string requestUri);
member this.GetAsync : string -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function GetAsync (requestUri As String) As Task(Of HttpResponseMessage)

参数

requestUri
String String String String

请求发送到的 URI。 The Uri the request is sent to.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>读取 (包括内容) 的整个响应后,将完成对象。The returned Task<TResult> object will complete after the whole response (including content) is read.

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

以异步操作将 GET 请求发送给指定 URI。 Send a GET request to the specified Uri as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(Uri ^ requestUri);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (Uri requestUri);
member this.GetAsync : Uri -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function GetAsync (requestUri As Uri) As Task(Of HttpResponseMessage)

参数

requestUri
Uri Uri Uri Uri

请求发送到的 URI。 The Uri the request is sent to.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>读取 (包括内容) 的整个响应后,将完成对象。The returned Task<TResult> object will complete after the whole response (including content) is read.

GetAsync(String, HttpCompletionOption) GetAsync(String, HttpCompletionOption) GetAsync(String, HttpCompletionOption) GetAsync(String, HttpCompletionOption)

用以异步操作的 HTTP 完成选项发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(System::String ^ requestUri, System::Net::Http::HttpCompletionOption completionOption);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (string requestUri, System.Net.Http.HttpCompletionOption completionOption);
member this.GetAsync : string * System.Net.Http.HttpCompletionOption -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function GetAsync (requestUri As String, completionOption As HttpCompletionOption) As Task(Of HttpResponseMessage)

参数

requestUri
String String String String

请求发送到的 URI。 The Uri the request is sent to.

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption HttpCompletionOption

指示操作应视为已完成的时间的 HTTP 完成选项值。 An HTTP completion option value that indicates when the operation should be considered completed.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>对象将完成基于completionOption读取部分或全部 (包括内容) 的响应后的参数。The returned Task<TResult> object will complete based on the completionOption parameter after the part or all of the response (including content) is read.

GetAsync(String, CancellationToken) GetAsync(String, CancellationToken) GetAsync(String, CancellationToken)

用以异步操作的取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with a cancellation token as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(System::String ^ requestUri, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (string requestUri, System.Threading.CancellationToken cancellationToken);
member this.GetAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

参数

requestUri
String String String String

请求发送到的 URI。 The Uri the request is sent to.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

可由其他对象或线程用以接收取消通知的取消标记。 A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>读取 (包括内容) 的整个响应后,将完成对象。The returned Task<TResult> object will complete after the whole response (including content) is read.

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

用以异步操作的 HTTP 完成选项发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(Uri ^ requestUri, System::Net::Http::HttpCompletionOption completionOption);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (Uri requestUri, System.Net.Http.HttpCompletionOption completionOption);
member this.GetAsync : Uri * System.Net.Http.HttpCompletionOption -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function GetAsync (requestUri As Uri, completionOption As HttpCompletionOption) As Task(Of HttpResponseMessage)

参数

requestUri
Uri Uri Uri Uri

请求发送到的 URI。 The Uri the request is sent to.

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption HttpCompletionOption

指示操作应视为已完成的时间的 HTTP 完成选项值。 An HTTP completion option value that indicates when the operation should be considered completed.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>对象将完成基于completionOption读取部分或全部 (包括内容) 的响应后的参数。The returned Task<TResult> object will complete based on the completionOption parameter after the part or all of the response (including content) is read.

GetAsync(Uri, CancellationToken) GetAsync(Uri, CancellationToken) GetAsync(Uri, CancellationToken)

用以异步操作的取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with a cancellation token as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(Uri ^ requestUri, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (Uri requestUri, System.Threading.CancellationToken cancellationToken);
member this.GetAsync : Uri * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

参数

requestUri
Uri Uri Uri Uri

请求发送到的 URI。 The Uri the request is sent to.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

可由其他对象或线程用以接收取消通知的取消标记。 A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>读取 (包括内容) 的整个响应后,将完成对象。The returned Task<TResult> object will complete after the whole response (including content) is read.

GetAsync(String, HttpCompletionOption, CancellationToken) GetAsync(String, HttpCompletionOption, CancellationToken) GetAsync(String, HttpCompletionOption, CancellationToken)

用以异步操作的 HTTP 完成选项和取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(System::String ^ requestUri, System::Net::Http::HttpCompletionOption completionOption, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (string requestUri, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken);
member this.GetAsync : string * System.Net.Http.HttpCompletionOption * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

参数

requestUri
String String String String

请求发送到的 URI。 The Uri the request is sent to.

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption HttpCompletionOption

指示操作应视为已完成的时间的 HTTP 完成选项值。 An HTTP completion option value that indicates when the operation should be considered completed.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

可由其他对象或线程用以接收取消通知的取消标记。 A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>对象将完成基于completionOption读取部分或全部 (包括内容) 的响应后的参数。The returned Task<TResult> object will complete based on the completionOption parameter after the part or all of the response (including content) is read.

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

用以异步操作的 HTTP 完成选项和取消标记发送 GET 请求到指定的 URI。 Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ GetAsync(Uri ^ requestUri, System::Net::Http::HttpCompletionOption completionOption, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> GetAsync (Uri requestUri, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken);
member this.GetAsync : Uri * System.Net.Http.HttpCompletionOption * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

参数

requestUri
Uri Uri Uri Uri

请求发送到的 URI。 The Uri the request is sent to.

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption HttpCompletionOption

指示操作应视为已完成的时间的 HTTP 完成选项值。 An HTTP completion option value that indicates when the operation should be considered completed.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

可由其他对象或线程用以接收取消通知的取消标记。 A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

表示异步操作的任务对象。 The task object representing the asynchronous operation.

Exceptions

由于基础问题(如网络连接性、DNS 失败、服务器证书验证或超时),请求失败。 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. 返回Task<TResult>对象将完成基于completionOption读取部分或全部 (包括内容) 的响应后的参数。The returned Task<TResult> object will complete based on the completionOption parameter after the part or all of the response (including content) is read.

Applies to