Action Results in MVC

What is Action Result?

Action Result is basically the return type or result for your action method. ActionResult is the base class for all action results. Namespace for this is System.Web.MVC.

If you need to return multiple action result then you can use ActionResult as return type.

The following table shows the built- in action result types and the action helper methods that return them.

Action Result Helper Method Description
ViewResult View Renders a view as web page
PartialViewResult PartialView Renders a partial view, which defines a section of a view that can be rendered inside another view.
RedirectResult Redirect Redirects to another action method by using URL
RedirectToRouteResult RedirectToAction or RedirectToRoute Redirects to another action method
ContentResult Contnet Returns a user-defined contnet type
JsonResult Json Returns serilized json object
JavaScriptResult JavaScript Returns a script that can be executed on the client.
HttpStatusCodeResult (None) Returns a specific HTTP response code and description.
HttpUnauthorizedResult (None) Returns the result of an unauthorized HTTP request.
HttpNotFoundResult HttpNotFound Indicates the requested resource was not found.
FileResult File Returns binary output to write to the response.
FileContentResult Controller.File(Byte[], String) or Controller.File(Byte[], String, String) Sends the contents of a binary file to the response.
FilePathResult Controller.File(String, String) or Controller.File(String, String, String) Sends the contents of a file to the response.
FileStreamResult Controller.File(Stream, String) or Controller.File(Stream, String, String) Sends binary content to the response through a stream.
EmptyResult (None) Represents a return value that is used if the action method must return a null result (void).

Helper Methods overloads:

  1. View
    1. View()  
    2. View(IView view)  
    3. View(object model)  
    4. View(string viewName)  
    5. View(IView view, object model)  
    6. View(string viewName, object model)  
    7. View(string viewName, string masterName)  
    8. View(string viewName, string masterName,object model) 
  2. PartialView
    1. PartialView()  
    2. PartialView(object model)  
    3. PartialView(string viewName)  
    4. PartialView(string viewName, object model) 
  3. Redirect
    1. Redirect(string url) 
  4. RedirectToAction
    1. RedirectionToAction(string actionName)  
    2. RedirectionToAction(string actionName, object routeValues)  
    3. RedirectionToAction(string actionName, string contollerName)  
    4. RedirectionToAction(string actionName, RouteValueDictionary routeValues)  
    5. RedirectionToAction(string actionName, string contollerName, object routeValues)  
    6. RedirectionToAction(string actionName, string contollerName, RouteValueDictionary routeValues) 
  5. RedirectToRoute
    1. RedirectToRoute(object routeValues)  
    2. RedirectToRoute(string routeName)  
    3. RedirectToRoute(RouteValueDictionary routeValues)  
    4. RedirectToRoute(string routeName, object routeValues)  
    5. RedirectToRoute(string routeName, RouteValueDictionary routeValues) 
  6. Content
    1. Content(string content)  
    2. Content(string content, string contentType)  
    3. Content(string content, string contentType, Encoding contentEncoding) 
  7. Json
    1. Json(object data)  
    2. Json(object data, JsonRequestBehavior behaviour)  
    3. Json(object data,string contentType)  
    4. Json(object data,string contentType, JsonRequestBehavior behaviour)  
    5. Json(object data,string contentType, Encoding contentEncoding)  
    6. Json(object data,string contentType, Encoding contentEncoding, JsonRequestBehavior behaviour) 
  8. Javascript
    1. Javascript(string script) 
  9. HttpNotFound
    1. HttpNotFound()  
    2. HttpNotFound(string statusDescription) 
  10. File
    1. File(byte[] fileContents,string contentType)  
    2. File(string fileName,string contentType)  
    3. File(Stream fileStream,string contentType)  
    4. File(byte[] fileContents,string contentType,string fileDownloadName)  
    5. File(string fileName,string contentType,string fileDownloadName)  
    6. File(Stream fileStream,string contentType,string fileDownloadName) 
Next Recommended Reading Action Method Parameters In ASP.NET MVC