0 votes
in C Sharp by

 List the various return types of a controller action method.

1 Answer

0 votes
by

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

0 votes
asked Nov 2, 2023 in ReactJS by AdilsonLima
0 votes
asked Oct 18, 2019 in C Sharp by Robin
...