IActionResult and ActionResult<T>

The IActionResult interface defines the contract <indexentry content="HTTP response:ActionResult"> for action method responses. The default implementation of the interface is provided by the ActionResult and ActionResult<T> types, but ASP.NET Core provides many derived response types that you can use to fully control the HTTP response that will be generated. Here is a short list of some of them:

  • EmptyResult: Generates an HTTP response with a success status code (200 OK) and an empty body.
  • ObjectResult: Generates a response with a body, where the body is a serialization of an object you provide. The object is serialized to the content type that was requested by the client. 
  • BadRequestResult: Generates a response ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.