Επεξεργασία

Κοινή χρήση μέσω


HttpClient.PutAsync Method

Definition

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

Overloads

PutAsync(String, HttpContent)

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

PutAsync(Uri, HttpContent)

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

PutAsync(String, HttpContent, CancellationToken)

Send a PUT request with a cancellation token as an asynchronous operation.

PutAsync(Uri, HttpContent, CancellationToken)

Send a PUT request with a cancellation token as an asynchronous operation.

Remarks

This operation will not block.

PutAsync(String, HttpContent)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

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

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

Parameters

requestUri
String

The Uri the request is sent to.

content
HttpContent

The HTTP request content sent to the server.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri must be an absolute URI or BaseAddress must be set.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

.NET Core and .NET 5 and later only: The request failed due to timeout.

The provided request URI is not valid relative or absolute URI.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the whole response (including content) is read.

Note

In case of timeout, different exceptions are thrown on different .NET implementations.

Applies to

PutAsync(Uri, HttpContent)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

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

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ PutAsync(Uri ^ requestUri, System::Net::Http::HttpContent ^ content);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (Uri requestUri, System.Net.Http.HttpContent content);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (Uri? requestUri, System.Net.Http.HttpContent content);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (Uri? requestUri, System.Net.Http.HttpContent? content);
member this.PutAsync : Uri * System.Net.Http.HttpContent -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function PutAsync (requestUri As Uri, content As HttpContent) As Task(Of HttpResponseMessage)

Parameters

requestUri
Uri

The Uri the request is sent to.

content
HttpContent

The HTTP request content sent to the server.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri must be an absolute URI or BaseAddress must be set.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

.NET Core and .NET 5 and later only: The request failed due to timeout.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the whole response (including content) is read.

Note

In case of timeout, different exceptions are thrown on different .NET implementations.

Applies to

PutAsync(String, HttpContent, CancellationToken)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Send a PUT request with a cancellation token as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ PutAsync(System::String ^ requestUri, System::Net::Http::HttpContent ^ content, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (string requestUri, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (string? requestUri, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (string? requestUri, System.Net.Http.HttpContent? content, System.Threading.CancellationToken cancellationToken);
member this.PutAsync : string * System.Net.Http.HttpContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function PutAsync (requestUri As String, content As HttpContent, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)

Parameters

requestUri
String

The Uri the request is sent to.

content
HttpContent

The HTTP request content sent to the server.

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

The requestUri must be an absolute URI or BaseAddress must be set.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

.NET Core and .NET 5 and later only: The request failed due to timeout.

The provided request URI is not valid relative or absolute URI.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the whole response (including content) is read.

Note

In case of timeout, different exceptions are thrown on different .NET implementations.

Applies to

PutAsync(Uri, HttpContent, CancellationToken)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Send a PUT request with a cancellation token as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ PutAsync(Uri ^ requestUri, System::Net::Http::HttpContent ^ content, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (Uri requestUri, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (Uri? requestUri, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsync (Uri? requestUri, System.Net.Http.HttpContent? content, System.Threading.CancellationToken cancellationToken);
member this.PutAsync : Uri * System.Net.Http.HttpContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function PutAsync (requestUri As Uri, content As HttpContent, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)

Parameters

requestUri
Uri

The Uri the request is sent to.

content
HttpContent

The HTTP request content sent to the server.

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

The requestUri must be an absolute URI or BaseAddress must be set.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

.NET Core and .NET 5 and later only: The request failed due to timeout.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task<TResult> object will complete after the whole response (including content) is read.

Note

In case of timeout, different exceptions are thrown on different .NET implementations.

Applies to