Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MVC3
I want to know the difference between ViewResult and ActionResult

What will be the difference of below two action methods? and how can one decide when to use ViewResult or ActionResult
public ActionResult Index()
       {
 
           return View();
       }
 
public ViewResult Index()
       {
 
           return View();
       }
Posted 19-Oct-11 1:05am
Edited 4-Oct-12 4:27am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

ActionResult -is an abstract class that can have several subtypes:

ViewResult - Renders a specifed view to the response stream
  Permalink  
Comments
Marcus Kramer at 4-Oct-12 9:28am
   
Please don't answer questions that are this old and already have answers. The likelihood that the OP is still looking for an answer to this question over 1 year later is pretty slim.
Don Nichol at 20-Dec-13 18:17pm
   
Other people come here looking for answers, not just the OP. Answers are always appreciated.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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
  Permalink  
Comments
CHill60 at 27-Feb-14 8:38am
   
To quote Marcus Kramer "Please don't answer questions that are this old and already have answers. The likelihood that the OP is still looking for an answer to this question over 2 years later is pretty slim.". The comment from Don Nichol does not apply as you have copied this from this 2 year old post[^]
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 165
1 Sergey Alexandrovich Kryukov 134
2 Sebastiaan Meijerink 131
3 Rana Waqas 110
4 Maciej Los 84
0 Sergey Alexandrovich Kryukov 6,558
1 OriginalGriff 6,288
2 Peter Leow 2,534
3 Abhinav S 2,358
4 Maciej Los 2,352


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 27 Feb 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100