ASP.NET MVC interview questions and answers:-What is the difference between "ActionResult" and "ViewResult" in MVC??
Recently lots of interview questions are asked around ASP.NET MVC. This is one of the favorite ASP.NET MVC interview question which making circles around.
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".
Also read ASP.NET MVC Interview questions: - What is the difference between tempdata ,viewdata and viewbag?
In case you are new to MVC, you watch MVC training videos by Click on Learn MVC step by step.