What is ActionResult in ASP.NET MVC?

ASP.NET MVC Controllers & Actions Basic 1–2 Yrs2–3 Yrs Conceptual 1 min read

Quick Answer

ActionResult is the base type for what a controller action returns. It represents a deferred command — “render this view”, “return this JSON”, “redirect there”, “send a 404” — that the framework executes after filters run. Helper methods like View(), Json(), RedirectToAction(), NotFound() and Ok() create the specific result types.

ActionResult is the base class for whatever a controller action returns. Instead of writing to the response, the action returns a result object that describes what should happen — render a view, return JSON, redirect, send a 404 — and the framework executes that after the filters have run. You create them with helpers: View(), Json(), RedirectToAction(), NotFound(), Ok(). For the return type I usually use IActionResult when an action has more than one possible outcome, and in Core Web API I use ActionResult<T> so I can return either the object or a status result and still get good Swagger output.

An action doesn't write to the response directly; it returns a result object and the framework executes it. Common types:

  • ViewResult (View(model)) — renders a Razor view.
  • PartialViewResult — renders a partial, for AJAX fragments.
  • JsonResult (Json(data)) — serialises to JSON.
  • RedirectResult / RedirectToActionResult — 302/301 redirect.
  • StatusCodeResult, NotFoundResult, BadRequestResult, OkObjectResult — bare status codes / with a body.
  • FileResult — streams a file.
  • ContentResult — raw string with a content type.

Return type choices:

  • IActionResult — the interface; use when an action can return different result types.
  • ActionResult<T> (Core) — lets you return either T (serialised) or a result like NotFound(), and improves API documentation.
  • A concrete type like ViewResult — fine when there is only one outcome, and slightly clearer.