List the various return types of a controller action method.

devquora
devquora

Posted On: Feb 22, 2018

 

There is total of nine return types we can use to return results from a controller to view. The base type of all these result types is ActionResult.

  1. ViewResult (View): This return type is used to return a webpage from an action method.
  2. PartialviewResult (Partialview): This return type is used to send a part of a view that will be rendered in another view.
  3. RedirectResult (Redirect): This return type is used to redirect to any other controller and action method depending on the URL.
  4. RedirectToRouteResult (RedirectToAction, RedirectToRoute): This return type is used when we want to redirect to any other action method.
  5. ContentResult (Content): This return type is used to return HTTP content type like text/plain as the result of the action.
  6. jsonResult (JSON): This return type is used when we want to return a JSON message.
  7. javascriptResult (javascript): This return type is used to return JavaScript code that will run in the browser.
  8. FileResult (File): This return type is used to send binary output in response.
  9. EmptyResult: This return type is used to return nothing (void) in the result.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    MVC Interview Questions

    What is MVC (Model view controller)?

     Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a giv..

    MVC Interview Questions

    What is Razor in MVC?

     ASP.NET MVC has always supported the concept of “view engines” – which are the pluggable modules, which practica..

    MVC Interview Questions

    Explain attribute based routing in MVC?

     In ASP.NET MVC 5.0 we have a new attribute route,by using the “Route” attribute we can define the URL structure. F..