HttpClient.DeleteAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Send a DELETE request to the specified Uri as an asynchronous operation.
Overloads
DeleteAsync(String) |
Send a DELETE request to the specified Uri as an asynchronous operation. |
DeleteAsync(Uri) |
Send a DELETE request to the specified Uri as an asynchronous operation. |
DeleteAsync(String, CancellationToken) |
Send a DELETE request to the specified Uri with a cancellation token as an asynchronous operation. |
DeleteAsync(Uri, CancellationToken) |
Send a DELETE request to the specified Uri with a cancellation token as an asynchronous operation. |
DeleteAsync(String)
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
Send a DELETE request to the specified Uri as an asynchronous operation.
public:
System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ DeleteAsync(System::String ^ requestUri);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (string requestUri);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (string? requestUri);
member this.DeleteAsync : string -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function DeleteAsync (requestUri As String) As Task(Of HttpResponseMessage)
Parameters
- requestUri
- String
The Uri the request is sent to.
Returns
The task object representing the asynchronous operation.
Exceptions
The request message was already sent by the HttpClient instance.
-or-
The requestUri
is not an absolute URI.
-or-
BaseAddress is not 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.
- HttpRequestException is thrown on all applicable .NET Framework versions.
- TaskCanceledException without any inner exception is thrown on all applicable .NET Core versions.
- TaskCanceledException that nests a TimeoutException is thrown on .NET 5 and later versions.
Applies to
DeleteAsync(Uri)
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
Send a DELETE request to the specified Uri as an asynchronous operation.
public:
System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ DeleteAsync(Uri ^ requestUri);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (Uri requestUri);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (Uri? requestUri);
member this.DeleteAsync : Uri -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function DeleteAsync (requestUri As Uri) As Task(Of HttpResponseMessage)
Parameters
- requestUri
- Uri
The Uri the request is sent to.
Returns
The task object representing the asynchronous operation.
Exceptions
The request message was already sent by the HttpClient instance.
-or-
The requestUri
is not an absolute URI.
-or-
BaseAddress is not 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.
- HttpRequestException is thrown on all applicable .NET Framework versions.
- TaskCanceledException without any inner exception is thrown on all applicable .NET Core versions.
- TaskCanceledException that nests a TimeoutException is thrown on .NET 5 and later versions.
Applies to
DeleteAsync(String, CancellationToken)
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
Send a DELETE request to the specified Uri with a cancellation token as an asynchronous operation.
public:
System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ DeleteAsync(System::String ^ requestUri, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (string requestUri, System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (string? requestUri, System.Threading.CancellationToken cancellationToken);
member this.DeleteAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function DeleteAsync (requestUri As String, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)
Parameters
- requestUri
- String
The Uri the request is sent to.
- 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 request message was already sent by the HttpClient instance.
-or-
The requestUri
is not an absolute URI.
-or-
BaseAddress is not 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.
- HttpRequestException is thrown on all applicable .NET Framework versions.
- TaskCanceledException without any inner exception is thrown on all applicable .NET Core versions.
- TaskCanceledException that nests a TimeoutException is thrown on .NET 5 and later versions.
Applies to
DeleteAsync(Uri, CancellationToken)
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
- Source:
- HttpClient.cs
Send a DELETE request to the specified Uri with a cancellation token as an asynchronous operation.
public:
System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ DeleteAsync(Uri ^ requestUri, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (Uri requestUri, System.Threading.CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> DeleteAsync (Uri? requestUri, System.Threading.CancellationToken cancellationToken);
member this.DeleteAsync : Uri * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function DeleteAsync (requestUri As Uri, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)
Parameters
- requestUri
- Uri
The Uri the request is sent to.
- 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 request message was already sent by the HttpClient instance.
-or-
The requestUri
is not an absolute URI.
-or-
BaseAddress is not 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.
- HttpRequestException is thrown on all applicable .NET Framework versions.
- TaskCanceledException without any inner exception is thrown on all applicable .NET Core versions.
- TaskCanceledException that nests a TimeoutException is thrown on .NET 5 and later versions.