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

 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. about云资源汇总指引V1.4:包括hadoop,openstack,nosql,虚拟化

    hadoop资料 云端云计算2G基础课程 (Hadoop简介.安装与范例) 炼数成金3G视频分享下载 虚拟机三种网络模式该如何上网指导此为视频 Hadoop传智播客七天hadoop(3800元)视频, ...

  2. 在Visual Studio中利用NTVS创建Pomelo项目

    刚看新闻,才知道微软发布了Node.js Tools for Visual Studio(NTVS),受够了WebStorm输入法Bug的困扰,这下终于可以解脱了.以Pomelo为例,运行命令:pom ...

  3. algorithm@ Strongly Connected Component

    Strongly Connected Components A directed graph is strongly connected if there is a path between all ...

  4. HDU-4627 The Unsolvable Problem 简单数学

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 对n除个2,然后考虑下奇偶... //STATUS:C++_AC_15MS_228KB #inc ...

  5. hdoj 2120 Ice_cream's world I【求成环数】

    Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. [Objective-c 基础 - 2.3] 继承、组合

    A.继承的实现: is a 1.不允许子类.父类存在相同的成员变量 2.方法调用优先原则:子类调用方法的时候,优先从本类寻找,若无则向上在父类中寻找 3.重写:子类重新实现父类的方法,覆盖父类之前的方 ...

  7. position跟display、margin collapse、overflow、float这些特性相互叠加后会怎么样?

    这是寒冬大神提出的一个题目,刚开始看到这题的时候完全不知道从什么地方回答起好,题目内容比较广泛,找不到针对点.后来我觉得这个题目应该能拆成几个点来回答:1.'display'.'position' 和 ...

  8. iOS Instruments内存检测使用

    Instruments 可以帮我们了解到应用程序使用内存的几个方面: 全局内存使用情况(Overall Memory Use): 从全局的角度监测应用程序的内存使用情况,捕捉非预期的或大幅度的内存增长 ...

  9. android获取mac地址方法

    http://www.cnblogs.com/xioapingguo/p/4037513.html 网上找的,记录一下 public static String getMacAdress(){ Wif ...

  10. 检查class排座位

    在写这篇文章之前,xxx已经写过了几篇关于改检查class主题的文章,想要了解的朋友可以去翻一下之前的文章     每日一道理 灯,带有一种明亮的光,每当深夜来临,是它陪伴着你,如此默默无闻.它是平凡 ...