3

I'm looking for a list of the inbuilt (and 3rd party would be a bonus) ActionResults you have available to you in a controller in ASP.NET MVC.

So far I've discovered the following:

  • ContentResult - this.Content()
  • ActionResult - this.View()
  • JsonResult - this.Json()
  • JavascriptResult - this.Javascript()
  • PartialViewResult - this.PartialView()

Have I missed any useful ones that are out there?

Chris S
  • 64,770
  • 52
  • 221
  • 239
  • For your future reference you could easily check **all** action results on a controller using .Net Reflector tool. You'll just check Controller's source code and see it all. Same goes for anything else you may be looking for in the future (even the inner workings of a particular functionality) – Robert Koritnik Dec 20 '10 at 11:09
  • There's an even easier way: http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult.aspx and http://msdn.microsoft.com/en-us/library/system.web.mvc.controller_methods.aspx - but that doesn't give me 3rd party ones – Chris S Feb 24 '12 at 19:37

3 Answers3

11

From this source:

  • ContentResult
    Writes a string value directly into the HTTP response.

  • EmptyResult
    Does not write to the HTTP response.

  • FileContentResult
    Takes the contents of a file (represented as an array of bytes) and write the contents into the HTTP response.

  • FilePathResult
    Takes the contents of a file at the given location and writes the contents into the HTTP response.

  • FileStreamResult
    Takes a file stream produced by the controller and writes the stream into the HTTP response.

  • HttpUnauthorizedResult
    A special result used by authorization filters when authorization checks fail.

  • JavaScriptResult
    Responds to the client with a script for the client to execute.

  • JsonResult
    Responds to the client with data in JavaScript Object Notation (JSON).

  • RedirectResult
    Redirects the client to a new URL.

  • RedirectToRouteResult
    Renders the specified view to respond with an HTML fragment (typically used in AJAX scenarios).

  • PartialViewResult
    Renders the specified view to respond with an HTML fragment (typically used in AJAX scenarios).

  • ViewResult
    Renders the specified view and responds to the client with HTML.

Community
  • 1
  • 1
Chris S
  • 64,770
  • 52
  • 221
  • 239
5

3rd party: MVCcontrib XmlResult

Gregoire
  • 24,219
  • 6
  • 46
  • 73
  • Hopefully Microsoft will see the value in putting XmlResult in the MVC core by default for version 2.0. – BuddyJoe Aug 14 '09 at 15:43
3

The book, ASP.NET MVC 1.0, has the following results (p 235): EmptyResult, ContentResult, JsonResult, RedirectResult, RedirectToRouteResult, ViewResult, PartialViewResult, FilePathResult, FileContentResult, FileStreamResult, JavaScriptResult

You can find out more specifics about each one here

Joseph Yaduvanshi
  • 20,241
  • 5
  • 61
  • 69
  • Thanks for the link, this one gives them too which I didn't find before I asked the question: http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult(VS.100).aspx – Chris S Aug 12 '09 at 16:32