編號 | 函式型別名稱 | 回傳方法 | 展示網址 |
1 | ViewResult |
View() new ViewResult() |
https://youtu.be/8aGJ8-gDERM |
2 | JavaScriptResult |
Jacascript() |
https://youtu.be/c4USf1yIpkU |
3 | ContentReuslt | Content() | https://youtu.be/0dSPD6FoSnA |
4 | FileResult | File() | https://youtu.be/3_dLaiXKr_s |
5 | JsonResult | Json() | https://youtu.be/9VgA1Ba2Vhs |
6 | EmptyResult | new EmptyResult() | https://youtu.be/mVWmlMMbcXY |
7 | HttpStatusCodeResult | new HttpStatusCodeResult() | https://youtu.be/Y0hvGtiXSuE |
8 | RedirectResult | new RedirectResult() | https://youtu.be/-iCSMkKRpnw |
9 | RedirectToRouteResult | RedirectToAction() | https://youtu.be/mvY-COTNMh4 |
1、[ ViewResult ]
[解說]
visual studio 2015 預設都會產生第一種,也較為常人所用。(三種效果都相同)
(1) 函式型別 ActionResult , 回傳為 View()
(2) 函式型別 ActionResult , 回傳為 ViewResult()
(3) 函式型別 ViewResult , 回傳為 ViewResult()
2、[ JavaScriptResult ]
(1) 函式型別 ActionResult , 回傳為 JavaScript() - 型別通用型
(2) 函式型別 JavaScriptResult , 回傳為 JavaScript() - 限制JavaScript
3、[ ContentResult ]
(1) 函式型別 ActionResult , 回傳為 Content( "html內容" ,"text/html" ) - 型別通用型
(2) 函式型別 ContentResult , 回傳為 Content( "html內容" ,"text/html" ) -
(3) 展示效果
4、[ FileResult ]
(1) 函式型別 ActionResult , 回傳為 File(iStream, "application/zip", fileName) - 型別通用型
(2) 函式型別 FileResult , 回傳為 File(iStream, "application/zip", fileName) -
4、[ JsonResult ]
(1) 函式型別 ActionResult , 回傳為 Json(new { tempList = tempList }, "text/json" , JsonRequestBehavior.AllowGet) - 型別通用型
(2) 函式型別 JsonResult , 回傳為 Json(new { tempList = tempList }, "text/json" , JsonRequestBehavior.AllowGet) -
6、[ EmptyResult ]
(1) 函式型別 ActionResult , 回傳為 new EmptyResult() - 型別通用型
(2) 函式型別 EmptyResult , 回傳為 new EmptyResult() -
(3) 呈現畫面
7、[HttpStatusCodeResult]
(1) 函式型別 ActionResult , 回傳為 new HttpStatusCodeResult() - 型別通用型
(2) 函式型別 HttpStatusCodeResult , 回傳為 new HttpStatusCodeResult() -
(3) 呈現畫面
8、[ RedirectResult ]
(1) 函式型別 ActionResult , 回傳為 new RedirectResult() - 型別通用型
(2) 函式型別 RedirectResult , 回傳為 new RedirectResult() -
(3)畫面呈現
[導頁前]
[導頁後]
9、[ RedirectToRouteResult ]
(1) 函式型別 ActionResult , 回傳為 RedirectToAction() - 型別通用型
(2) 函式型別 RedirectToRouteResult, 回傳為 RedirectToAction() -
(3)畫面呈現
[導頁前]
[導頁後]