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.
return Content('This is my content result');
2- ViewResult:
This return type is used to return webpage from action method or in short term it return a view as a Webpage.
return View('Index');
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.
return Redirect('/Home/index');
5- PartialViewResult:
It return a partial view to the response or It returns a part of a view that will rendered in another view.
public PartialViewResult PartialViewExp()
{
return PartialView('Login');
}
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.
return new EmptyResult();
9- FileResult:
This return type is use to returns binary file content to the response.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Action 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.
return Content('This is my content result');2- ViewResult:
This return type is used to return webpage from action method or in short term it return a view as a Webpage.
return View('Index');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.
return Redirect('/Home/index');5- PartialViewResult:
It return a partial view to the response or It returns a part of a view that will rendered in another view.
public PartialViewResult PartialViewExp() { return PartialView('Login'); }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.