Updated on 30 Sep 2025 by Admin

What is ActionResult?

In all the articles, I have used ActionResult while returning a view. But in reality, an MVC View actually returns a ViewResult.

Now, the question arises, then how were we capable of returning a view even when the return type was ActionResult? Leave this question for a moment and consider the following scenarios:

For real-world applications, clients can be anyone. This means that a request to the controller can come directly from the browser via a URL or UI, or it may come from any JavaScript client, such as jQuery (Ajax).

  • A browser always expects an HTML result back as a response while
  • JavaScript most probably requires a JSON response.

Now, with the single return type, two different responses can't be sent. And only because of the difference in the return type, you will end up creating two different methods for the same purpose. It will cause duplicate code in your application.

public ActionResult GetEmployees()
{
List<employee> employeeList = new List<employee> () {
new Employee(){Id=1,Name="Michael",Gender="Male",Age=23},
new Employee(){Id=2,Name="John",Gender="Male",Age=26},
new Employee(){Id=3,Name="Lucy",Gender="female",Age=20},
};
return View(employeeList);
}
public ActionResult GetEmployeeList()
{
List<employee> employeeList = new List<employee> () {
new Employee(){Id=1,Name="Michael",Gender="Male",Age=23},
new Employee(){Id=2,Name="John",Gender="Male",Age=26},
new Employee(){Id=3,Name="Lucy",Gender="female",Age=20},
};
return Json(employeeList,JsonRequestBehavior.AllowGet);
}

To solve such a problem in MVC, we have ActionResult.

ActionResult is actually the parent of all other results, and every other response type is derived from ActionResult. So, it can be used to return any response like JsonResult, ViewResult, ContentResult, etc.

ActionResult
ActionResult
public ActionResult GetEmployees()
{
string type = Request.QueryString["type"];
List<employee> employeeList = new List<employee> () {
new Employee(){Id=1,Name="Michael",Gender="Male",Age=23},
new Employee(){Id=2,Name="John",Gender="Male",Age=26},
new Employee(){Id=3,Name="Lucy",Gender="female",Age=20},
};
if(type=="Json")
{
return Json(employeeList, JsonRequestBehavior.AllowGet);
}
return View(employeeList);
}

Now, as you can observe, if anyone asks for a JSON type, JsonResult will be sent; else, ViewResult will be sent.

Action Result
ActionResult

Now, I think you have your answer on how we were able to return a View with ActionResult as the return type.

In conclusion, we can say that all public methods of the Controller class in ASP.NET MVC are called Action Methods. The action method can return any result type, such as EmptyResult, JsonResult, ViewResult, PartialViewResult, RedirectResult, RedirectToRouteResult, etc. It doesn't make sense to remember all these Result Types and return them accordingly. So, we have a Parent Type as ActionResult, and all other Result Types inherit from this parent type. This allows us to return an ActionResult instead of the exact Result type, and it will be automatically cast into the appropriate Result Type at runtime by virtue of Polymorphism.


Sharpen Your Skills with These Next Guides