Profile photo
Submitted by Sam Buchana
on October 3rd, 2012 at 17:28:29 EST

MVC - Difference Between Viewresult() and ActionResult()

What is the difference between using ViewResult() and ActionResult() in ASP.NET MVC framework?

For example:

public ActionResult About()

public ViewResult About()

Profile photo
Replied by SBajra
on October 4th, 2012 at 09:51:29 EST
ActionResult is an abstract class that can have several sub-types. ViewResult is derived from ActionResult abstract class.

List of sub-classes derived from ActionResult abstract class:
a) ViewResult - Renders a specifed view to the response stream
b) PartialViewResult - Renders a specifed partial view to the response stream
c) EmptyResult - An empty response is returned
d) RedirectResult - Performs an HTTP redirection to a specifed URL
e) RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data
f) JsonResult - Serializes a given ViewData object to JSON format
g) JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client
h) ContentResult - Writes content to the response stream without requiring a view
i) FileContentResult - Returns a fle to the client
j) FileStreamResult - Returns a fle to the client, which is provided by a Stream
k) FilePathResult - Returns a fle to the client

Accepted Answer