---
title: "What is the difference between ActionResult and ViewResult?"  
description: "What is the difference between ActionResult and ViewResult?"  
author: "Anonymous User"  
published: 2019-10-21  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/33673/what-is-the-difference-between-actionresult-and-viewresult  
category: "asp.net mvc"  
tags: ["asp.net mvc", "mvc"]  
reading_time: 2 minutes  

---

# What is the difference between ActionResult and ViewResult?

- The ActionResult is an abstract class while ViewResult derives from the ActionResult class. ActionResult has several derived classes like ViewResult, JsonResult, FileStreamResult, and so on.
- The ActionResult can be used to exploit polymorphism and dynamism. So if you are returning different types of views dynamically, ActionResult is the best thing. For example in the below code snippet, you can see we have a simple action called DynamicView. Depending on the flag (IsHtmlView) it will either return a ViewResult or JsonResult.

## Answers

### Answer by Anonymous User

(1). In the term of MVC programming pattern, the ActionResult is an abstract class while ViewResult derives from the ActionResult class. ActionResult has several derived classes like ViewResult, JsonResult, FileStreamResult, and so on.

(2). In the term of MVC programming pattern, the ActionResult can be used to exploit polymorphism and dynamism. So if you are returning different types of views dynamically, ActionResult is the best thing. For example in the below code snippet, you can see we have a simple action called DynamicView. Depending on the flag (IsHtmlView) it will either return a ViewResult or JsonResult.

### Answer by Anonymous User

- The ActionResult is an abstract class while ViewResult derives from the ActionResult class. ActionResult has several derived classes like ViewResult, JsonResult, FileStreamResult, and so on.
- The ActionResult can be used to exploit polymorphism and dynamism. So if you are returning different types of views dynamically, ActionResult is the best thing. For example in the below code snippet, you can see we have a simple action called DynamicView. Depending on the flag (IsHtmlView) it will either return a ViewResult or JsonResult.


---

Original Source: https://www.mindstick.com/interview/33673/what-is-the-difference-between-actionresult-and-viewresult

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
