码迷,mamicode.com
首页 > Web开发 > 详细

ASP.NET MVC RedirectToRoute类

时间:2014-06-06 17:38:45      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

  Controller类中与RedirectToRoute相关的方法有两个:RedirectToAction()和RedirectToRoute()。

  1、RedirectToAction()

  ? 转到同一个Controller的另外一个Action

bubuko.com,布布扣
protected internal RedirectToRouteResult RedirectToAction(string actionName);
bubuko.com,布布扣
bubuko.com,布布扣
public ActionResult Index()
{
    return RedirectToAction("List");
}
bubuko.com,布布扣

  ? 转到指定Controller的Action

bubuko.com,布布扣
protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName);
bubuko.com,布布扣
bubuko.com,布布扣
public ActionResult Index()
{
    return RedirectToAction("List", "Member");
}
bubuko.com,布布扣

  ? 转到MemberController的List Action方法中,并加上"page"这个RouteValue值

bubuko.com,布布扣
protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName, object routeValues);
bubuko.com,布布扣
bubuko.com,布布扣
public ActionResult Index()
{
    return RedirectToAction("List", "Member", new { page = 2 });
}
bubuko.com,布布扣

  2、RedirectToRoute()

  ? 转到同一个Controller的另外一个Action

bubuko.com,布布扣
protected internal RedirectToRouteResult RedirectToRoute(object routeValues);
bubuko.com,布布扣
bubuko.com,布布扣
public ActionResult Index()
{
    return RedirectToRoute(new { action = "List" });
}
bubuko.com,布布扣

  ? 转到指定Controller的Action

bubuko.com,布布扣
public ActionResult Index()
{
    return RedirectToRoute(new { controller="Member", action = "List" });
}
bubuko.com,布布扣

  ? 转到MemberController的List Action方法中,并加上"page"这个RouteValue值

bubuko.com,布布扣
public ActionResult Index()
{
    return RedirectToRoute(new { controller = "Member", action = "List", page = 3 });
}
bubuko.com,布布扣

ASP.NET MVC RedirectToRoute类,布布扣,bubuko.com

ASP.NET MVC RedirectToRoute类

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/libingql/p/3766377.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!