ViewResult =>ViewResult Renders a view as a web page.
PartialViewResult =>As the name describe
PartialViewResult=> renders the partial view.
RedirectResult =>When you want to redirect to another action method we will use RedirectResult
RedirectToRouteResult =>Redirect to another action method
ContentResult =>Returns a user-defined content type
JsonResult =>When you want to return a serialized JSON object
JavaScriptResult=>Returns a script that can be executed on the client
FileResult=>Returns a binary output to write to the response EmptyResult
ViewResult =>ViewResult Renders a view as a web page.
PartialViewResult =>As the name describe
PartialViewResult=> renders the partial view.
RedirectResult =>When you want to redirect to another action method we will use RedirectResult
RedirectToRouteResult =>Redirect to another action method
ContentResult =>Returns a user-defined content type
JsonResult =>When you want to return a serialized JSON object
JavaScriptResult=>Returns a script that can be executed on the client
FileResult=>Returns a binary output to write to the response EmptyResult
ViewResult =>ViewResult Renders a view as a web page.
PartialViewResult =>As the name describe
PartialViewResult=> renders the partial view.
RedirectResult =>When you want to redirect to another action method we will use RedirectResult
RedirectToRouteResult =>Redirect to another action method
ContentResult =>Returns a user-defined content type
JsonResult =>When you want to return a serialized JSON object
JavaScriptResult=>Returns a script that can be executed on the client
FileResult=>Returns a binary output to write to the response EmptyResult
ViewResult =>Renders a view as a web page.
PartialViewResult =>As the name describe
PartialViewResult=> renders the partial view.
RedirectResult =>When you want to redirect to another action method we will use RedirectResult
RedirectToRouteResult =>Redirect to another action method
ContentResult =>Returns a user-defined content type
JsonResult =>When you want to return a serialized JSON object
JavaScriptResult=>Returns a script that can be executed on the client
FileResult=>Returns a binary output to write to the response EmptyResult
ViewResult =>ViewResult Renders a view as a web page.
PartialViewResult =>As the name describe
PartialViewResult=> renders the partial view.
RedirectResult =>When you want to redirect to another action method we will use RedirectResult
RedirectToRouteResult =>Redirect to another action method
ContentResult =>Returns a user-defined content type
JsonResult =>When you want to return a serialized JSON object
JavaScriptResult=>Returns a script that can be executed on the client
FileResult=>Returns a binary output to write to the response EmptyResult
ActionResult Helper Method Description
ViewResult View ViewResult Renders a view as a web page.
PartialViewResult PartialView As the name describe PartialViewResult renders the partial view.
RedirectResult Redirect When you want to redirect to another action method we will use RedirectResult
RedirectToRouteResult RedirectToRoute Redirect to another action method
ContentResult Content Returns a user-defined content type
JsonResult Json When you want to return a serialized JSON object
JavaScriptResult JavaScript Returns a script that can be executed on the client
FileResult File Returns a binary output to write to the response
EmptyResult (None) returns a null result
explained with an example and attached sample code, how to upload files to database in asp.net using FileUpload control and then download saved or stored files from SQL Server database using GridView control
the different type of results in mvc are
ViewResult, PartialViewResult, RedirectResult, RedirectToRouteResult, ContentResult, JsonResult, JavaScriptResult, FileResult, EmptyResult
The ActionResult is the base class for all the return types . it may be either return viewresult , return javascriptresult or else . there are 13 types of results , including return file , return file result , return partial view , return content , return content result etc.
The ActionResult is the base class for all the return types . it may be either return viewresult , return javascriptresult or else . there are 13 types of results , including return file , return file result , return partial view , return content , return content result etc.
There are multiple results in MVC,Action Result is base for all result.
System.Object
System.Web.Mvc.ActionResult
System.Web.Mvc.ContentResult
System.Web.Mvc.EmptyResult
System.Web.Mvc.FileResult
System.Web.Mvc.HttpStatusCodeResult
System.Web.Mvc.JavaScriptResult
System.Web.Mvc.JsonResult
System.Web.Mvc.RedirectResult
System.Web.Mvc.RedirectToRouteResult
System.Web.Mvc.ViewResultBase
Reference
http://www.c-sharpcorner.com/UploadFile/dacca2/various-return-types-from-mvc-controller/
Action method returns the Results ActionResult. User response is encapsulated in ActionResult.
ActionResult class is the base class for all action results.
Types of Results:
ContentResult
EmptyResult
FileResult
HttpStatusCodeResult
JavaScriptResult
JsonResult
RedirectResult
RedirectToRouteResult
ViewResultBase
Out these results most widely used result types are:
ContentResult
JsonResult
FileResult
ActionResult
Refernce:
https://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult(v=vs.118).aspx
1. ViewResult - Renders a specified view to the response stream
2. PartialViewResult - Renders a specified partial view to the response stream
3. EmptyResult - An empty response is returned
4. RedirectResult - Performs an HTTP redirection to a specified URL
5. RedirectToRouteResult - Performs an HTTP redirection to a URL that is
determined by the routing engine, based on given route data
6. JsonResult - Serializes a given ViewData object to JSON format
7. JavaScriptResult - Returns a piece of JavaScript code that can be executed on the
client
8. ContentResult - Writes content to the response stream without requiring a view
9. FileContentResult - Returns a file to the client
10. FileStreamResult - Returns a file to the client, which is provided by a Stream
11. FilePathResult - Returns a file to the client