博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP.NET MVC RedirectToRoute类[转]
阅读量:4700 次
发布时间:2019-06-09

本文共 1323 字,大约阅读时间需要 4 分钟。

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 });}

转载于:https://www.cnblogs.com/xzitluyang/p/6042245.html

你可能感兴趣的文章
【Oracle 集群】ORACLE DATABASE 11G RAC 知识图文详细教程之集群概念介绍(一)
查看>>
Java内部类
查看>>
SQL Server 2008杀数据库连接
查看>>
ExtJs自学教程(1):一切从API開始
查看>>
MfC 进度条控件
查看>>
java推断字符串是否为乱码
查看>>
设计牛人——设计入门答疑番外篇有感
查看>>
JavaScript基础介绍
查看>>
H5 以及 CSS3
查看>>
Potted Flower(线段树+dp)
查看>>
Angular之双向数据绑定(上)
查看>>
20155307 2016-2017-2 《Java程序设计》第4周学习总结
查看>>
TimeJob权限问题 拒绝访问
查看>>
负载均衡,会话保持,session同步
查看>>
jira安装备忘
查看>>
IOS-项目中常见文件介绍
查看>>
观察者-学历差距造成的差距有多大
查看>>
bzoj 2528: [Poi2011]Periodicity【kmp+构造】
查看>>
下载CentOS镜像
查看>>
django orm 之makemigrations和migrate命令
查看>>