首先我覺得action的跳轉大致可以這樣歸一下類,跳轉到同一控制器內的action和不同控制器內的action、帶有參數的action跳轉和不帶參數的action跳轉。
一、RedirectToAction(“Index”);//一個參數時在本Controller下,不傳入參數。
二、RedirectToAction(ActionName,ControllerName) //可以直接跳到別的Controller.
三、RedirectToRoute(new {controller=“Home”,action=“Index”});//可跳到其他controller
四、RedirectToRoute(new {controller=“Home”,action=“Index”, id=param});//可跳到其他controller,帶參數。
五、Response.Redirect(“Index?id=1”);//適用于本controller下的方法名稱,可帶參數。
六、return Redirect(“Index”);//適用于本controller下的方法名稱。
七、return View(“Index”); //直接顯示對應的頁面 不經過執行Controller的方法。
八、return View("~/Views/Home/Index.aspx");//這種方法是寫全路徑,直接顯示頁面,不經過Controller方法
九、return View();//直接顯示頁面,不經過Controller方法