Hands-On Full-Stack Web Development with ASP.NET Core
by Tamir Dresher, Amir Zuker, Shay Friedman
Explicit return type
The simplest form of an action method is the one where the return type is a predefined .NET type, such as primitives or classes you have created. When the method returns a value, the ASP.NET Core pipeline create a success response (with the status code 200 OK) and serializes the value with a formatter that is suitable to the content type that the client requested (via the Accept header in the HTTP request) or with the configured default formatter (the JSON formatter, unless configured otherwise).
Although returning an explicit predefined type is the simplest way to create actions, it's also the most restricted way. My recommendation is not to use this method, and instead, configure all of your actions to return ActionResult<T> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access