先看看我们例子用到的路由表

 routes.MapRouteWithName(
name: "ProductDetail",
url: "{Platform}/Product/{ProductID}",
defaults: new { controller = "Home", action = "Product"}
);
  • 方法1
protected internal RedirectToRouteResult RedirectToRoute(
Object routeValues
) eg: return RedirectToRoute(new
{
controller = "Home", //控制器
action = "Product", //Action
ProductID = , //参数
nickName = "wahaha" //参数
});
  • 方法2
protected internal RedirectToRouteResult RedirectToRoute(
string routeName,
Object routeValues
) eg: 重定向到该路由 return RedirectToRoute("ProductDetail", new { Platform = "WeChat", ProductID = });
  • 方法3
protected internal RedirectToRouteResult RedirectToRoute(
RouteValueDictionary routeValues
) eg: return RedirectToRoute(new System.Web.Routing.RouteValueDictionary(new {
action= "Product",
controller = "Home",
ProductId = //参数
}));
  • 方法4
protected internal virtual RedirectToRouteResult RedirectToRoute(
string routeName,
RouteValueDictionary routeValues
) eg:
return RedirectToRoute("ProductDetail", new System.Web.Routing.RouteValueDictionary(new
{
Platform = "WeChat",
ProductID = 1 }));

Controller中利用RedirectToRoute重定向的问题的更多相关文章

  1. MVC中利用ActionFilterAttribute过滤关键字

    在开发过程中,有时候会对用户输入进行过滤,以便保证平台的安全性.屏蔽的方法有很多种,但是今天我说的这种主要是利用MVC中的ActionFilterAttribute属性来实现.由于MVC天然支持AOP ...

  2. SpingMVC中利用BindingResult将错误信息返回到页面中

    SpingMVC中利用BindingResult将错误信息返回到页面中. ActionFrom中: private String name; private String password; get( ...

  3. ASP.NET MVC 学习4、Controller中添加SearchIndex页面,实现简单的查询功能

    参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/examining-the-edit-method ...

  4. Controller 中Action 返回值类型 及其 页面跳转的用法

        •Controller 中Action 返回值类型 View – 返回  ViewResult,相当于返回一个View 页面. -------------------------------- ...

  5. 六、 从Controller中访问模板数据(ASP.NET MVC5 系列)

    在这一章节中,我们将创建一个新的MoviesController类,写代码获取movie数据并用视图模板将它们显示到浏览器中. 在我们进行下一操作之前先Build the application.如果 ...

  6. springmvc 解决 controller 中出现死循环并 stackoverflow 的问题

    这是因为这个controller中的方法返回值为void类型,且没有request response这类衍生的重定向,或者返回值为String,但是是null等等的情况,都会引起死循环,然后stack ...

  7. asp.net mvc 3.0 知识点整理 ----- (2).Controller中几种Action返回类型对比

    通过学习,我们可以发现,在Controller中提供了很多不同的Action返回类型.那么具体他们是有什么作用呢?它们的用法和区别是什么呢?通过资料书上的介绍和网上资料的查询,这里就来给大家列举和大致 ...

  8. SpringMVC之八:基于SpringMVC拦截器和注解实现controller中访问权限控制

    SpringMVC的拦截器HandlerInterceptorAdapter对应提供了三个preHandle,postHandle,afterCompletion方法. preHandle在业务处理器 ...

  9. spring mvc controller间跳转 重定向 传参(转)

    spring mvc controller间跳转 重定向 传参 url:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ ...

随机推荐

  1. OpenCV在Debug和Release两种模式下布恩那个同时运行的问题

    首先,可以肯定的说,两者是可以随时切换进行运行的,若不能运行,必定是配置出了问题 以Debugx64和Releasex64为例: 在Releasex64模式下,我配置好了各种路径: 于是乎,我切换到D ...

  2. nodejs学习:师哥自家的twenty博客框架

    这周继续为DTree项目预热,学习sails框架的搭建和结构熟悉.正好师哥在做一个nodejs的CMS框架twenty,他们用的就是sails框架. 结构 首先简单了解一下结构.在jade文件里由an ...

  3. Java Serializable(序列化)的理解和总结、具体实现过程(转)

    原文地址:http://www.apkbus.com/forum.php?mod=viewthread&tid=13576&fromuid=3402 Java Serializable ...

  4. 把pgboucer做成postgresql服务

    把pgbouncer启动命令加入到postgresql服务配置里面.这样方便操作 vi /etc/init.d/postgresql 加入如下红色命令.路径换成你的pgbouncer安装目录 in s ...

  5. 用RelativeLayout布局可以在imageview中写上文字

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  6. MyBatis简介与配置MyBatis+Spring+MySql

    MyBatis学习 之 一.MyBatis简介与配置MyBatis+Spring+MySql MyBatis学习 之 二.SQL语句映射文件(1)resultMap MyBatis学习 之 二.SQL ...

  7. #Cocos2d+lua#android+Eclipse工程编译设置

    用Elicpse编译cocos2d+lua的工程几点注意点记录: 1.设置工程属性Windows->Preferences->NDK目录 2.右键Android Tools->Add ...

  8. hadoop学习;block数据块;mapreduce实现样例;UnsupportedClassVersionError异常;关联项目源代码

    对于开源的东东,尤其是刚出来不久,我认为最好的学习方式就是能够看源代码和doc,測试它的样例 为了方便查看源代码,关联导入源代码的项目 先前的项目导入源代码是关联了源代码文件 block数据块,在配置 ...

  9. Project Management - 1) Schedule Your Project

    1. 根据项目的理解,列出主要的里程碑. (初始甘特图) 2. 多使用即时贴,甘特图可以贴在墙上以供项目组成员提醒. 3. 切忌过早细化项目日程,这样会让老板或出资人以为项目中几乎没有风险, 他们会把 ...

  10. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...