This code will help you to understand how to send an HTTP DELETE request using HttpClient in Blazor.
An HTTP Delete request can be sent to delete a resource from the API server using the DeleteAsync () method provided by the HttpClient class.
Razor
@page "/employee/delete" @inject HttpClient Http @inject NavigationManager Navigate .. .. .. .. .. .. .. .. .. .. .. .. @code { Employee emp = new Employee(); protected async Task Delete() { await Http.DeleteAsync("api/Employee/Delete/" + Convert.ToInt32(empID)); Navigate.NavigateTo("/employee"); } }
Web API
[HttpDelete] [Route("api/Employee/Delete/{id}")] public void Delete(int id) { employee.DeleteEmployee(id); }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
An HTTP Delete request can be sent to delete a resource from the API server using the DeleteAsync () method provided by the HttpClient class.
Razor
Web API
need an explanation for this answer? contact us directly to get an explanation for this answer