HOW MANY TYPES OF RESULTS IN MVC?

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
 721  View(s)
Ratings:
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.
  1. Anupam Mishra

    Post:135

    Points:949
    Re: How many types of results in MVC?

    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.



Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!