首页 > 代码库 > ASP.NET MVC RedirectToRoute类
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 });}
ASP.NET MVC RedirectToRoute类
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。