共用方式為


HttpMessageInvoker.Send(HttpRequestMessage, CancellationToken) 方法

定義

使用指定的要求和取消權杖來傳送 HTTP 要求。

public:
 virtual System::Net::Http::HttpResponseMessage ^ Send(System::Net::Http::HttpRequestMessage ^ request, System::Threading::CancellationToken cancellationToken);
public virtual System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
abstract member Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
override this.Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
abstract member Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
override this.Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
Public Overridable Function Send (request As HttpRequestMessage, cancellationToken As CancellationToken) As HttpResponseMessage

參數

request
HttpRequestMessage

要傳送的 HTTP 要求訊息。

cancellationToken
CancellationToken

用於取消作業的取消語彙基元。

傳回

HTTP 回應訊息。

屬性

例外狀況

request 以前是 null

適用於 HTTP/2 或更高版本,或是 RequestVersionOrHigher 啟用要求版本升級時。

-或-

如果使用衍生自 HttpContent 的自訂類別不會覆寫 SerializeToStream(Stream, TransportContext, CancellationToken) 方法。

-或-

如果使用衍生自 HttpMessageHandler 的自訂類別不會覆寫 Send(HttpRequestMessage, CancellationToken) 方法。

取消權杖已取消。 此例外狀況會儲存在傳回的工作中。

適用於