Controller response helper methods

The ASP.NET Core ControllerBase base class, from which all the controllers inherit, provides a few helper methods for creating responses instead of manually creating and setting instances of IActionResult derived types. Here is a short list of some of the popular ones:

  • Ok(...): Creates an OkResult object with or without content
  • StatusCode(int statusCode): Creates a response with a given status code
  • BadRequest(...): Creates a BadRequestObjectResult with a 400 status code and a body 

For a complete list, refer to the ControllerBase documentation, available at https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.controllerbase?view=aspnetcore-2.0#Methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.75.165