Home » Programming » ASP.NET » What is the Difference between Viewresult() and ActionResult() in ASP.NET MVC ?

What is the Difference between Viewresult() and ActionResult() in ASP.NET MVC ?

If you are a ASP.NET MVC Web application developer and want to know the difference between Viewresult() and ActionResult() in ASP.NET MVC , here we go . In this blog post , we will explain the main difference between Viewresult() and ActionResult() in ASP.NET MVC.

What is the Difference between Viewresult() and ActionResult() in ASP.NET MVC ?

In the Controller , one could use the below syntax

public ViewResult EditEmployee()

{

return View();

}

public ActionResult EditEmployee()

{

return View();

}

In the above example , only the return type varies . one returns ViewResult whereas the other one returns ActionResult .

ActionResult is an abstract class . It can accept ViewResult , PartialViewResult, EmptyResult , RedirectResult , RedirectToRouteResult , JsonResult , JavaScriptResult , ContentResult , FileContentResult , FileStreamResult , FilePathResult etc.

The ViewResult is a subclass of ActionResult.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>