ASP.NET MVC Controller Action Return Types

An action method is used to return an instance of any class which is derived from ActionResult class. Some of the return types of a controller action method are:

  • ViewResult : It is used to return a webpage from an action method
  • PartialViewResult : It is used to send a section of a view to be rendered inside another view.
  • JavaScriptResult : It is used to return JavaScript code which will be executed in the user’s browser.
  • RedirectResult : Based on a URL, It is used to redirect to another controller and action method.
  • ContentResult : It is an HTTP content type may be of text/plain. It is used to return a custom content type as a result of the action method.
  • JsonResult : It is used to return a message which is formatted as JSON.
  • FileResult : It is used to send binary output as the response.
  • EmptyResult : It returns nothing as the result.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s