Results.NotFound creates an HTTP 404 response when a request cannot produce the requested result, such as when an ASCII-art font is invalid. section 3.1.2
A route can select Results.NotFound after a Boolean-returning method reports failure. Results.Content and Results.NotFound both implement IResult, so a ternary expression can choose between them. section 3.1.2
Invalid-font response
The route writes ASCII art when AsciiArt.Write succeeds; otherwise, it returns Results.NotFound(). section 3.1.2
Listing 3.16 Returning 404 if font is invalid
app.MapGet("/{text}",
(string text, string? font) =>
AsciiArt.Write(text, out var asciiText, font) #1
? Results.Content(asciiText!) #2
: Results.NotFound()); #3
Inspect the focused minimal-route listing that uses an out parameter, Results.Content, and Results.NotFound in one response decision. section 3.1.2
