MVC页面重定向页面跳转
MVC控制器中几种页面跳转的方法。 1.Response.Redirect();方法 namespace MvcDemo.Controllers { [HandleError] public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "欢迎使用 ASP.NET MVC!"; Response.Redirect("User/News"); return View(); } public ActionResult About() { return View(); } } } 2.Return Redirect();方法 namespace MvcDemo.Controllers { [HandleError] public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "欢迎使用 ASP.NET MVC!"; return Redirect("User/News"); } public ActionResult About() { return View(); } } } 3.Return RedirectToAction();方法 namespace MvcDemo.Controllers { [HandleError] public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "欢迎使用 ASP.NET MVC!"; return RedirectToAction("News","User"); } public ActionResult About() { return View(); } } }