What is ActionResult in asp.net MVC? Explain its Type.
What is ActionResult in asp.net MVC? Explain its type.
92711-Mar-2022
Updated on 11-Mar-2022
Home / DeveloperSection / Forums / What is ActionResult in asp.net MVC? Explain its type.
What is ActionResult in asp.net MVC? Explain its Type.
Steilla Mitchel
11-Mar-2022Action Results in ASP.Net MVC :
When we create a controller in asp.net mvc then a ActionResult method is automatically generated named as Index that returns a view(). In asp.net mvc an ActionResult is an Abstract class and ActionResult is a return type of controller method. Each ActionResult return different type of result. If we need to return an image then we need use FileResult method which is built-in method in asp.net mvc.
Types of ActionResult in MVC:
There are many types of ActionResults that are used in mvc given as below,
1- ContentResult:
It returns user type content and http content type like text.
2- ViewResult:
This return type is used to return webpage from action method or in short term it return a view as a Webpage.
3- RedirectToRouteResult:
It is used to redirect to another controller and action method.
4- RedirectResult:
It return to a specific action method based on URL.
5- PartialViewResult:
It return a partial view to the response or It returns a part of a view that will rendered in another view.
6- jsonResult:
This return type is used to return Json message.
7- javascriptResult:
This return type is used to return javascript code that is run on client's browser.
8- EmptyResult:
This is returns a result that does nothing.
9- FileResult:
This return type is use to returns binary file content to the response.