June 30, 2009

MVC – Types of ActionResults

Types of ActionResults:
. ViewResult—Represents an ASP.NET MVC view.
. PartialViewResult—Represents a fragment of an ASP.NET MVC view.
. RedirectResult—Represents a redirection to another controller action or URL.
. ContentResult—Represents raw content sent to the browser.
. JsonResult—Represents a JavaScript Object Notation result (This is useful in Ajax
. FileResult—Represents a file to be downloaded.
. EmptyResult—Represents no result returned by an action.
. HttpUnauthorizedResult—Represents an HTTP Unauthorized status code.
. JavaScriptResult—Represents a JavaScript file.
. RedirectToRouteResult—Represents a redirection to another controller action or
URL using route values.

List of controller methods that return ActionResults:

. View( )—Returns a ViewResult
. PartialView() —Returns a PartialViewResult
. RedirectToAction() —Returns a RedirectToRouteResult
. Redirect() —Returns a RedirectResult
. Content() —Returns a ContentResult
. Json( )—Returns a JsonResult
. File( )—Returns a FileResult
. JavaScript()—Returns a JavaScriptResult
. RedirectToRoute( )—Returns a RedirectToRouteResult