Here we will understand difference between
View Result and Action result. Basically
Action result is an abstract class
which has subtypes and the View result
class is derived from Action Result
class.
“View Result” is derived from Action Result , so Action Result in MVC is an abstract parent class
“View Result” is derived from Action Result , so Action Result in MVC is an abstract parent class
See the below code
public ActionResult Index()
{
return
View();
}
|
In the above code we can see that it is
returning a “View Result” object and cause of polymorphism this “View Result”
object automatically types casted for the parent class means “Action result”.
Action Result Subtypes:-
- ViewResult - Renders a specified view to the response stream
- PartialViewResult - Renders a particular partial view to the
response stream
- EmptyResult - An empty response is given.
- RedirectResult - It Performs an HTTP redirect to a specified URL
- RedirectToRouteResult - Performs an HTTP redirection to a URL
that is decide by the routing engine, based on given data from route.
- JsonResult - Serializes a given View Data object to JSON format
- JavaScriptResult - Returns a piece of JavaScript code that
can be executed on the client
- ContentResult - its Write content to response stream without need of a
view
- FileContentResult - Returns a file to the client
- FileStreamResult - it Returns a file to the user, that is
provided through a Stream
- FilePathResult - it Returns a file to the user
No comments:
Post a Comment