What is the difference between ViewResult and ActionResult? Normally I call a View using an ActionResult, but I've already seen code with ViewResult. Then came this doubt.
What is the difference between ViewResult and ActionResult? Normally I call a View using an ActionResult, but I've already seen code with ViewResult. Then came this doubt.
ViewResult
drift ActionResult
. ActionResult
is abstract, and serves as a wildcard in return, which can be:
ViewResult
: It specifically returns a View ; PartialViewResult
: It specifically returns a Partial View ; EmptyResult
: Returns a response empty; RedirectResult
: Returns a statement from redirection to another address, not necessarily from your system; RedirectToRouteResult
: Returns a statement specific redirection to another route-based address of your system; JsonResult
: Returns a JSON ; JavaScriptResult
: Returns a code JavaScript generated on server to run on client; ContentResult
: Returns a result custom, such as a string, for example; FileContentResult
: Returns a file . Equivalent to FileResult
; FileStreamResult
: Returns a file whose read is based on an object of type % with% / a> or derivatives. Stream
: Returns a file based on a file system directory path of the server hosting your system. From an answer from the ASP.NET forum : ActionResult
is an abstract class, and has variás derived classes, including ViewResult
. If you are going to return your ViewResult method in your method, you can declare it by returning ActionResult as ViewResult.
Here are some classes derived from ActionResult: