I want the example controller below to return a status code 418 with no contents. Setting the status code is easy enough but then it seems like there is something that needs
this.HttpContext.Response.StatusCode = 418; // I'm a teapotHow to end the request?
Try other solution, just:
return StatusCode(418);
You could use StatusCode(???) to return any HTTP status code.
Also, you can use dedicated results:
Success:
return Ok() ← Http status code 200return Created() ← Http status code 201return NoContent(); ← Http status code 204Client Error:
return BadRequest(); ← Http status code 400return Unauthorized(); ← Http status code 401return NotFound(); ← Http status code 404
More details: