1.

What are the different return types of action methods of a controller in MVC?

Answer»

The base type for all the RETURN TYPES of action method is “Action Result”. Below are the various return types that can be used to return results from a controller action method. 

  1. ViewResult (View): This return type is used to return a webpage from the action method.
  2. PartialviewResult (Partial view the ): This is used to send part of a view that is GOING to render inside another view.
  3. RedirectResult (Redirect): This is used to redirect to any other controller and action method based on the URL.
  4. RedirectToRouteResult (RedirectToAction, RedirectToRoute): This is used  to redirect to any other action method.
  5. ContentResult (Content): This is used to return HTTP content type text/plain as the result.
  6. JSONResult (JSON): This is used to return JSON as a result.
  7. JavascriptResult (javascript): This is used to return the JavaScript CODE that will run in the browser.
  8. FileResult (File): This is used to return binary output as a response.
  9. EmptyResult: This is used when nothing (VOID) to return.


Discussion

No Comment Found