Linux 拨号vps windows公众号手机端

.net mvc跳转页面的方法是什么

lewis 6年前 (2019-01-13) 阅读数 10 #程序编程
文章标签 .netmvc

在ASP.NET MVC中,有几种方法可以实现页面的跳转:

  1. 使用Redirect方法进行页面跳转:
public ActionResult RedirectToPage()
{
return Redirect("/Home/Index");
}
  1. 使用RedirectToAction方法进行页面跳转:
public ActionResult RedirectToActionMethod()
{
return RedirectToAction("Index", "Home");
}
  1. 使用RedirectToRoute方法进行页面跳转:
public ActionResult RedirectToRouteMethod()
{
return RedirectToRoute(new { controller = "Home", action = "Index" });
}
  1. 使用View方法进行页面跳转(仅限于同一控制器内的视图):
public ActionResult GoToView()
{
return View("ViewName");
}

这些方法中,Redirect和RedirectToAction方法可以在控制器的任何地方使用,而RedirectToRoute方法和View方法则需要在控制器中返回一个ActionResult类型的结果。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门