All inbuilt ActionResults in ASP.NET MVC

前端 未结 3 1182
庸人自扰
庸人自扰 2021-01-14 03:49

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 discover

3条回答
  •  不思量自难忘°
    2021-01-14 04:43

    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.

提交回复
热议问题