Number of questions 1,751
Number of tests completed 248,330
Number of questions answered 3,716,082
Number of registered users 19,034
Sign In | Register
Skip Navigation Links
Question: What is the difference between “ActionResult” and “ViewResult”?
Answer1: ViewResult performs an HTTP redirection to a specifed URL
Answer2: ViewResult serializes a given ViewData object to JSON format
Answer3: ActionResult is an abstract class while ViewResult derives from ActionResult class
Answer4: ViewResult returns a file to the client, which is provided by a Stream while an ActionResult performs an HTTP redirection to a specifed URL
Answer5:
Answer: ActionResult is an abstract class while ViewResult derives from ActionResult class

Explaination: “ActionResult” is an abstract class while “ViewResult” derives from “ActionResult” class. “ActionResult” has several derived classes like “ViewResult” ,”JsonResult” , “FileStreamResult” and so on. “ActionResult” can be used to exploit polymorphism and dynamism. So if you are returning different types of view dynamically “ActionResult” is the best thing. For example in the below code snippet you can see we have a simple action called as “DynamicView”. Depending on the flag (“IsHtmlView”) it will either return “ViewResult” or “JsonResult”. public ActionResult DynamicView() { if (IsHtmlView) return View(); // returns simple ViewResult else return Json(); // returns JsonResult view }
Link:

Correctly answered: 6790
Incorrectly answered: 2844
Terms of Use
contact@quiznetonline.com Ver. 2.0.6783.38332