ActionResult Subtypes In MVC

  • ViewResult – Renders a specified view to the response stream.
  • PartialViewResult – Renders a specified partial view to the response stream.
  • EmptyResult – An empty response is returned.
  • RedirectResult – Performs an HTTP redirection to a specified URL.

What is ActionResult?

What is an ActionResult? An ActionResult is a return type of a controller method, also called an action method, and serves as the base class for *Result classes. Action methods return models to views, file streams, redirect to other controllers, or whatever is necessary for the task at hand.

Is ActionResult a concrete class?

ActionResult is an abstract class that represents the result of an action method.

What do you mean by ViewResult ()?

ViewResult represents a class that is used to render a view by using an IView instance that is returned by an IViewEngine object. View() creates an object that renders a view to the response.

What is difference between ActionResult and ViewResult?

ViewResult is a subclass of ActionResult. The View method returns a ViewResult. The only difference is that with the ActionResult one, your controller isn’t promising to return a view – you could change the method body to conditionally return a RedirectResult or something else without changing the method definition.

What is difference between ActionResult and IActionResult?

IActionResult is an interface and ActionResult is an implementation of that interface. ActionResults is an abstract class and action results like ViewResult, PartialViewResult, JsonResult, etc., derive from ActionResult. Let’s say you want to create an action result not catered to by MVC, say an XML result.

Can ActionResult return JSON?

JsonResult is one of the type of MVC action result type which returns the data back to the view or the browser in the form of JSON (JavaScript Object notation format). In this article we will learn about JsonResult by taking scenario to bind view using the JSON Data . So let’s see step by step.

What is the difference between ViewResult and ActionResult?

What is the difference between ActionResult and JsonResult?

Use JsonResult when you want to return raw JSON data to be consumed by a client (javascript on a web page or a mobile client). Use ActionResult if you want to return a view, redirect etc to be handled by a browser. ActionResult is an abstract class . JsonResult is subtype of ActionResult .

Can I return ActionResult instead of ViewResult?

ActionResult is the best thing if you are returning different types of views. ActionResult is an abstract class, and it’s base class for ViewResult class. In MVC framework, it uses ActionResult class to reference the object your action method returns.

What is partialviewresult in ASP NET MVC?

Let us first understand the need and use of ViewResult and then we will understand the need and use of PartialViewResult in ASP.NET MVC Application. The View Result in MVC is returning the result to a View Page. The View Result can return data to the View Page through the model class. The view page is a simple HTML page.

What is the difference between actionresult and viewviewresult?

ViewResult is a subclass of ActionResult. The View method returns a ViewResult. So really these two code snippets do the exact same thing.

What is the use of partpartialviewresult in Java?

PartialViewResult is used to return the partial view. Basically, it is a class which implements the ViewResultBase abstract class that used to render partial view. PartialViewResult class inherit from ViewResultBase class.

What are the properties of partialviewresult in Salesforce?

The following are the properties of PartialViewResult which are inherited from ViewResultBase. It does not uses layout page since it render in to the main view which has already layout page. It used to return the portion of web page instead of whole page. It does not fire all page events like main view.