在ASP.NET MVC中,有几种方法可以实现页面的跳转:
public ActionResult RedirectToPage()
{
return Redirect("/Home/Index");
}
public ActionResult RedirectToActionMethod()
{
return RedirectToAction("Index", "Home");
}
public ActionResult RedirectToRouteMethod()
{
return RedirectToRoute(new { controller = "Home", action = "Index" });
}
public ActionResult GoToView()
{
return View("ViewName");
}
这些方法中,Redirect和RedirectToAction方法可以在控制器的任何地方使用,而RedirectToRoute方法和View方法则需要在控制器中返回一个ActionResult类型的结果。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:怎么使用.net mvc框架跳转页面