Hello readers In this tutorial we are going to see what is the difference between ViewResult() and ActionResult() in ASP.NET MVC. This is a very interesting topic for interview point of view.
Difference between ViewResult() and ActionResult() in ASP.NET MVC:
|1-||ViewResult can return only view result type.||Action Result can return many types of results like PartialViewResult, JSONResult.|
|2-||ViewResult class is derived from the base class ActionResult.||ActionResult is a base class for ViewResult.|
|3-||It is a concrete class.||It is an abstract class.|
|4-||It is a concrete class so no subtypes available.|
ActionResult has many subtypes available:
If we are sure that our action method will return the only view we can go with ViewResult.
If our action method may return view or redirect to some URL we should go with ActionResult.
public ActionResult DynamicView(bool IsHtmlView)
- ASP.NET Web API Interview Questions.
- SQL Interview Questions and Answers.
- Interview Questions & Answers on .NET.
- Difference Between MVC Controller and Web API Controller.
I hope you understand the Difference between VieweResult() and ActionResult() in ASP.NET MVC. Your Feedback and comments are welcome to me.