liveBook · Manning

Result resource

As explained in Pro ASP.NET Core 7, Tenth Edition

An action result is an object representing a response produced by an MVC action method.

An action result is an object representing the response produced by an MVC action method. The action result system encapsulates reusable responses such as rendered views, redirects, and authorization prompts. section 2.3.3

Common action-result behaviors include:

  • Return a ViewResult so Razor locates a view and renders an HTML response. section 2.3.3
  • Return a RedirectResult to send the browser to another URL. section 2.3.3
  • Return an HttpUnauthorizedResult to prompt the user to log in. section 2.3.3
Listing 2.7 Rendering a view in the HomeController.cs file in the Controllers folder
using Microsoft.AspNetCore.Mvc;

namespace FirstProject.Controllers {

    public class HomeController : Controller {
        public ViewResult Index() {
            return View("MyView");
        }
    }
}

A HomeController action returns a named ViewResult, demonstrating the concrete MVC code behind rendered responses. section 2.3.3

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Defines the response abstraction and reuse role, while deferring detailed result types and usage patterns.
Examples
Uses ViewResult, RedirectResult, HttpUnauthorizedResult, and a HomeController action returning a view.
What you can do after
Apply it via MVC action methods to encapsulate reusable HTTP responses.
How it connects
Connects MVC action methods with views, Razor, view models, redirects, and authorization.

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 Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.