What is the difference between ViewResult() and ActionResult() in ASP.NET MVC?
public ViewResult Index()
{
return View();
}
public ActionResult Index()
{
return View();
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ActionResult is an abstract class that can have several subtypes.
ActionResult Subtypes
ViewResult – Renders a specifed view to the response stream
PartialViewResult – Renders a specifed partial view to the response stream
EmptyResult – An empty response is returned
RedirectResult – Performs an HTTP redirection to a specifed URL
RedirectToRouteResult – Performs an HTTP redirection to a URL that is determined by the
routing engine, based on given route data
JsonResult – Serializes a given ViewData object to JSON format
JavaScriptResult – Returns a piece of JavaScript code that can be executed on the client
ContentResult – Writes content to the response stream without requiring a view
FileContentResult – Returns a file to the client
FileStreamResult – Returns a file to the client, which is provided by a Stream
FilePathResult – Returns a file to the client
Resources