The HTTP PUT method is used to completely replace a resource on the API server. We can use the HttpClient to send a PUT request to an API server using the SendJsonAsync () method.
CSHTML
@page "/employee/edit"
@inject HttpClient Http
.. .. .. .. .. ..
.. .. .. .. .. ..
@code {
Employee emp = new Employee();
protected async Task UpdateEmployee()
{
await Http.SendJsonAsync(HttpMethod.Put, "api/Employee/Edit", emp);
UriHelper.NavigateTo("/employee");
}
}
Web API
[HttpPut]
[Route("api/Employee/Edit")]
public void Edit([FromBody]Employee employee)
{
if (ModelState.IsValid)
this.employee.UpdateEmployee(employee);
}
Reference link:
Share with