falah mahmood
falah mahmood

Reputation: 465

ASP.NET Web API Action Results

When we use a HttpGet action method to get resources we generally return Ok().

public IHttpActionResult Get() {
  var customers = context.customers.toList();
  return Ok(customers);
}

When we use HttpPost action method to create a record we return Created() with the location of the newly created resource.

When we use HttpPut to update a record what do we return? For example when we read records we return Ok() and for create we return Created()

And also what do we return for HttpDelete?

Upvotes: 1

Views: 757

Answers (1)

Ricardo Fontana
Ricardo Fontana

Reputation: 4813

According the tutorial in https://docs.asp.net/en/latest/tutorials/first-web-api.html, when you execute an HTTP PUT or HTTP DELETE you must return 204 (No content) code.

return new NoContentResult();

Upvotes: 2

Related Questions