[技術/MVC2] ActionResult Study Note [1].

  • 3624
  • 0
  • 2010-10-29

摘要:[技術/MVC2] ActionResult Study Note [1].

資料來源: ASP.NET MVC2 開發實戰
作者: Will 保哥

一. What is ActionResult?
==> 為 Action 執行的結果,但 ActionResult 不包含執行結果,而是包含執行回應時所需的資訊.

二. ActionResult 的種類

ContentResult
==> 回傳一個使用者自訂的文字內容
==> Controller Support Method: Content

EmptyResult
==> 不回傳任何資料
==> Controller 輔助方法: 無

JsonResult
==> 回傳已序列化為 Json 格式的資料
==> Contrller 輔助方法: Json

RedirectResult
==> 重新導向至指定的 URL.
==> Contrller 輔助方法: Redirect

RedirectToRouteResult
==> 重新導向至某個 Action 或 Route
==> Contrller 輔助方法: RedirectToAction, RedirectToRoute

ViewResult
==> 使用 IView instance 及 IViewEngine, 實際輸出資料者為 IViewEngine 及 View
==> Contrller 輔助方法: View

PartialViewResult
==> 回傳 userControl 的 View
==> Contrller 輔助方法: PartialView

FileResult
==> 以二進位串流方式回傳一個檔案資料
==> Contrller 輔助方法: File

JavaScriptResult
==> 回傳 Javascript 指令碼.
==> Contrller 輔助方法: JavaScript

黑貓仔的修練之路