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:
- View
- View()
- View(IView view)
- View(object model)
- View(string viewName)
- View(IView view, object model)
- View(string viewName, object model)
- View(string viewName, string masterName)
- View(string viewName, string masterName,object model)
- PartialView
- PartialView()
- PartialView(object model)
- PartialView(string viewName)
- PartialView(string viewName, object model)
- Redirect
- RedirectToAction
- RedirectionToAction(string actionName)
- RedirectionToAction(string actionName, object routeValues)
- RedirectionToAction(string actionName, string contollerName)
- RedirectionToAction(string actionName, RouteValueDictionary routeValues)
- RedirectionToAction(string actionName, string contollerName, object routeValues)
- RedirectionToAction(string actionName, string contollerName, RouteValueDictionary routeValues)
- RedirectToRoute
- RedirectToRoute(object routeValues)
- RedirectToRoute(string routeName)
- RedirectToRoute(RouteValueDictionary routeValues)
- RedirectToRoute(string routeName, object routeValues)
- RedirectToRoute(string routeName, RouteValueDictionary routeValues)
- Content
- Content(string content)
- Content(string content, string contentType)
- Content(string content, string contentType, Encoding contentEncoding)
- Json
- Json(object data)
- Json(object data, JsonRequestBehavior behaviour)
- Json(object data,string contentType)
- Json(object data,string contentType, JsonRequestBehavior behaviour)
- Json(object data,string contentType, Encoding contentEncoding)
- Json(object data,string contentType, Encoding contentEncoding, JsonRequestBehavior behaviour)
- Javascript
- Javascript(string script)
- HttpNotFound
- HttpNotFound()
- HttpNotFound(string statusDescription)
- File
- File(byte[] fileContents,string contentType)
- File(string fileName,string contentType)
- File(Stream fileStream,string contentType)
- File(byte[] fileContents,string contentType,string fileDownloadName)
- File(string fileName,string contentType,string fileDownloadName)
- File(Stream fileStream,string contentType,string fileDownloadName)