liveBook · Manning

Result resource

As explained in .NET in Action, Second Edition

ActionResult is an ASP.NET Core result abstraction that represents the outcome of handling a web request, including its response content and HTTP status code.

A result resource represents the response produced by handling a web request, including its content and HTTP status code. ASP.NET Core uses built-in results to return content, not-found responses, files, and other response types from minimal API actions. section 3.1.2

Use result resources when the default 200 response is not sufficient:

  • Return Results.NotFound when a requested font does not exist instead of silently selecting a default. section 3.1.2

Conditional response selection

An endpoint can call a method that reports success through a Boolean and supplies generated text through an out parameter, then select Results.Content or Results.NotFound accordingly.

How .NET in Action, Second Edition covers it

How deep it goes
Demonstrates conditional result selection and several built-in response types without detailing their internal implementations.
Examples
Uses ASCII-art content, invalid-font handling, and a JPEG barcode endpoint to demonstrate response choices.
What it assumes
Assumes familiarity with minimal API mappings and introduces out parameters while modifying an existing response-producing method.
What you can do after
Apply built-in Results methods to return content, not-found responses, and files from minimal API endpoints.
How it connects
Connects ActionResult with minimal APIs, MVC controllers, HTTP status codes, JSON, HTML, images, and out parameters.

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 .NET in Action, Second Edition. The section links point to the parts of the book it draws on.