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

 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. leetcode@ [136/137] Single Number & Single Number II

    https://leetcode.com/problems/single-number/ Given an array of integers, every element appears twice ...

  2. 避免Java应用中NullPointerException的技巧和最佳实践

    Java应用中抛出的空指针异常是解决空指针的最好方式,也是写出能顺利工作的健壮程序的关键.俗话说"预防胜于治疗",对于这么令人讨厌的空指针异常,这句话也是成立的.值得庆幸的是运用一 ...

  3. 使用PHP输出中文JSON字符串

    PHP 和 JavaScript 交互其实很方便,PHP 原生也提供了对 JSON 格式的支持.主要包括 JSON 编码和解码两个函数: 代码如下: json_endoce: http://cn.ph ...

  4. tomcat登陆WEB显示无权限问题&& tomcat无限循环启动问题

    tomcat登陆WEB显示无权限问题 The user specified as a definer (”@’%') does not exist 原因分析 因为创建视图使用的是xff@%用户(目前已 ...

  5. 获取EXe版本信息

    function GetVersionString(FileName: string): string;    var    VerInfoSize: DWORD;    VerInfo: Point ...

  6. AutoLayout框架Masonry使用心得

    AutoLayout框架Masonry使用心得 字数1769 阅读1481 评论1 喜欢17 我们组分享会上分享了页面布局的一些写法,中途提到了AutoLayout,会后我决定将很久前挖的一个坑给填起 ...

  7. iOS几个效果动画-------------------(实例详讲)qq粘性效果

    这几天做了一些简单iOS的效果图,感觉苹果官方已经帮我们做了很多了,我们只是站在巨人的肩膀上编程,这些也没什么难的,最难的也就是用到了初中的三角函数,先让大家看看这几个动画吧.先列这几个把,由上而下分 ...

  8. 高效使用Bitmaps(一) 大Bitmap的加载

    转载:http://my.oschina.net/rengwuxian/blog/182885 高效使用Bitmaps有什么好处? 我们常常提到的“Android程序优化”,通常指的是性能和内存的优化 ...

  9. android系统自带图标集合(android.R.drawable查看)

    alert_dark_frame alert_light_frame arrow_down_float arrow_up_float bottom_bar btn_default btn_defaul ...

  10. Javascript(jQuery)中绑定页面上所有按钮点击事件的几种方式

    方法一:使用document对象查找所有的按钮 [javascript] view plain copy 在CODE上查看代码片派生到我的代码片 //按照dom的方式添加事件处理 function B ...