ASP.NET MVC RedirectToRoute类
本文转载:http://www.cnblogs.com/libingql/p/3766377.html
Controller类中与RedirectToRoute相关的方法有两个:RedirectToAction()和RedirectToRoute()。
1、RedirectToAction()
◊ 转到同一个Controller的另外一个Action
protected internal RedirectToRouteResult RedirectToAction(string actionName);
public ActionResult Index() { return RedirectToAction("List"); }
◊ 转到指定Controller的Action
protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName);
public ActionResult Index() { return RedirectToAction("List", "Member"); }
◊ 转到MemberController的List Action方法中,并加上"page"这个RouteValue值
protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName, object routeValues);
public ActionResult Index() { return RedirectToAction("List", "Member", new { page = 2 }); }
2、RedirectToRoute()
◊ 转到同一个Controller的另外一个Action
protected internal RedirectToRouteResult RedirectToRoute(object routeValues);
public ActionResult Index() { return RedirectToRoute(new { action = "List" }); }
◊ 转到指定Controller的Action
public ActionResult Index() { return RedirectToRoute(new { controller="Member", action = "List" }); }
◊ 转到MemberController的List Action方法中,并加上"page"这个RouteValue值
public ActionResult Index() { return RedirectToRoute(new { controller = "Member", action = "List", page = 3 }); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。