-> ActionResult is an abstract class while ViewResult derives from ActionResult class. ActionResult has several derived classes like ViewResult, JsonResult, FileStreamResult and so on.
1 2 3 4 5 6 7 8 9 10 11 12 |
public ActionResult Index() { return View(); // this is a view result class } public ActionResult DynamicView(bool IsHtmlView) { if (IsHtmlView) return View(); // returns simple ViewResult else return Json(); // returns JsonResult view } |
- ViewResult -> Renders specific view to the response stream.
- PartialViewResult -> Renders a specified partial view
- JsonResult -> Serializes a given object to JSON format.
- RedirectResult -> Performs an HTTP redirection to a specified URL.