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

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

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. PHP编码规范整理,很全很实用(图文版)

    有一个组织叫做“php互操作性框架制定小组”,这个小组的主要目的是制定各种PHP编码规范的,下面就是我根据小组提供的建议整理的一些常用的编码规范. PSR-1: 1.PHP代码文件必须以<?ph ...

  2. 关于java对象的思考

    不可变对象和类 由不可变类创建的对象就是不可变对象,要使一个类成为不可变的,它必须满足下面的需求: 所有数据域都是私有的 没有修改器方法 没有一个访问器的方法,它会返回一个指向可变数据域的引用 看下面 ...

  3. [OC Foundation框架 - 19] 练习遇到的Bugs

    1.没有权限读取文件夹 The file “Homework2” couldn’t be opened because you don’t have permission to view it.   ...

  4. Umbraco中的ModelBuilder

    Umbraco中的ModelBuilder有以下几种形式 Pure Live models Dll models LiveDll models AppData models LiveAppData m ...

  5. hadoop 2.0 详细配置教程

    http://www.cnblogs.com/scotoma/archive/2012/09/18/2689902.html

  6. ThindPad x230 无法U盘启动

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  7. NSMutableAttributedString iOS 在UILabel显示不同的字体和颜色(转)

    在项目开发中,我们经常会遇到在这样一种情形:在一个UILabel 使用不同的颜色或不同的字体来体现字符串,在iOS 以后我们可以很轻松的实现这一点,官方的API 为我们提供了UILabel类的attr ...

  8. ios基础知识

    1获取系统语言设置 NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; NSArray *languages = ...

  9. 数据持久化(五)之CoreData

    @简单的说,Core Data就是能够存储到磁盘的对象图,[...]Core Data能够帮我们做非常多任务作.它能够作为软件的整个模型层. 它不只在磁盘上存储数据.也把我们须要的数据对象读取到内存中 ...

  10. AIR 程序开发系列 之五 保存数据的几种方式

    Local SharedObject 这种方法比较简单方便的保存少的数据到到设备中.你不用自己去管理这些数据,设备会自动管理他. SharedObject 在 flash.net 包中,继承自Even ...