liveBook · Manning

Result resource

As explained in Building Web APIs with ASP.NET Core

ActionResult is an ASP.NET Core action return type that can represent either a typed response value or an HTTP action result.

ActionResult<T> lets an ASP.NET Core action return either a successful typed value or an HTTP action result. For example, an action returning Task<ActionResult<RestDTO<Domain[]>>> can produce domain data when validation succeeds, or an ObjectResult containing validation details when it fails. section 6.2.3

Use the return type when an action must:

  • Return a JSON object for a successful request. section 6.2.3
  • Return different HTTP statuses, such as 501 for an unsupported page size or 400 for an invalid sort order. section 6.2.3

Verify both response paths

Call /Domains?pageSize=101 and /Domains?sortOrder=InvalidValue. Open the browser Network tab and inspect each HTTP status, not only the response body. section 6.2.3

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains the generic return-type change and manual validation branches, stopping short of framework internals.
Examples
Uses the Domains GET action, invalid pageSize and sortOrder queries, and browser Network-tab status inspection.
What it assumes
Assumes familiarity with ASP.NET Core actions and ModelState while demonstrating validation handling from the action boundary.
What you can do after
Apply it via ASP.NET Core MVC to return typed data or structured HTTP errors from one action.
How it connects
Connects model validation, ModelState, ObjectResult, ValidationProblemDetails, HTTP status codes, and response verification.

Also explained in

Compare how 4 books explain result resource →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.