Home > DeveloperSection > Forums > How many types of results in MVC?
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    February-07-2016 10:16 PM

 ASP.Net C#  ASP.Net  ASP.NET MVC 
Ratings:


 1 Reply(s)
 333  View(s)
Rate this:
Hi All,
How many types of results in MVC? Can anyone give me a types of results in MVC with some elaboration.
Thank you.


Anupam Mishra

Total Post:135

Points:949
Posted on    February-07-2016 11:02 PM

There are many types of result in mvc. ActionResult is a base class of all result in mvc .In Below we are given result hierarchy:
System.Object
  System.Web.Mvc.ActionResult
    System.Web.Mvc.ContentResult
    System.Web.Mvc.EmptyResult
    System.Web.Mvc.FileResult
    System.Web.Mvc.HttpStatusCodeResult
    System.Web.Mvc.JavaScriptResult
    System.Web.Mvc.JsonResult
    System.Web.Mvc.RedirectResult
    System.Web.Mvc.RedirectToRouteResult
    System.Web.Mvc.ViewResultBase

Here some of types of result in given below:

ActionResult: Action methods typically return a result that is known as an action result. The ActionResult class is the base class for all action results. we are decide which type of action result to return based on the task that the action method is performing. 

ContentResult: Represents a user-defined content type that is the result of an action method.

EmptyResult: Represents a result that does nothing, such as a controller action method that returns nothing.

FileResult: Represents a base class that is used to send binary file content to the response.

HttpStatusCodeResult: Provides a way to return an action result with a specific HTTP response status code and description.

JavaScriptResult: Sends JavaScript content to the response.

JsonResult: Represents a class that is used to send JSON-formatted content to the response.

RedirectResult: Controls the processing of application actions by redirecting to a specified URI.

RedirectToRouteResult: Represents a result that performs a redirection by using the specified route values dictionary.

ViewResultBase: Represents a base class that is used to provide the model to the view and then render the view to the response.




Don't want to miss updates? Please click the below button!

Follow MindStick