Controller中利用RedirectToRoute重定向的问题
先看看我们例子用到的路由表
- 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重定向的问题的更多相关文章
- MVC中利用ActionFilterAttribute过滤关键字
在开发过程中,有时候会对用户输入进行过滤,以便保证平台的安全性.屏蔽的方法有很多种,但是今天我说的这种主要是利用MVC中的ActionFilterAttribute属性来实现.由于MVC天然支持AOP ...
- SpingMVC中利用BindingResult将错误信息返回到页面中
SpingMVC中利用BindingResult将错误信息返回到页面中. ActionFrom中: private String name; private String password; get( ...
- ASP.NET MVC 学习4、Controller中添加SearchIndex页面,实现简单的查询功能
参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/examining-the-edit-method ...
- Controller 中Action 返回值类型 及其 页面跳转的用法
•Controller 中Action 返回值类型 View – 返回 ViewResult,相当于返回一个View 页面. -------------------------------- ...
- 六、 从Controller中访问模板数据(ASP.NET MVC5 系列)
在这一章节中,我们将创建一个新的MoviesController类,写代码获取movie数据并用视图模板将它们显示到浏览器中. 在我们进行下一操作之前先Build the application.如果 ...
- springmvc 解决 controller 中出现死循环并 stackoverflow 的问题
这是因为这个controller中的方法返回值为void类型,且没有request response这类衍生的重定向,或者返回值为String,但是是null等等的情况,都会引起死循环,然后stack ...
- asp.net mvc 3.0 知识点整理 ----- (2).Controller中几种Action返回类型对比
通过学习,我们可以发现,在Controller中提供了很多不同的Action返回类型.那么具体他们是有什么作用呢?它们的用法和区别是什么呢?通过资料书上的介绍和网上资料的查询,这里就来给大家列举和大致 ...
- SpringMVC之八:基于SpringMVC拦截器和注解实现controller中访问权限控制
SpringMVC的拦截器HandlerInterceptorAdapter对应提供了三个preHandle,postHandle,afterCompletion方法. preHandle在业务处理器 ...
- spring mvc controller间跳转 重定向 传参(转)
spring mvc controller间跳转 重定向 传参 url:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ ...
随机推荐
- PHP编码规范整理,很全很实用(图文版)
有一个组织叫做“php互操作性框架制定小组”,这个小组的主要目的是制定各种PHP编码规范的,下面就是我根据小组提供的建议整理的一些常用的编码规范. PSR-1: 1.PHP代码文件必须以<?ph ...
- 关于java对象的思考
不可变对象和类 由不可变类创建的对象就是不可变对象,要使一个类成为不可变的,它必须满足下面的需求: 所有数据域都是私有的 没有修改器方法 没有一个访问器的方法,它会返回一个指向可变数据域的引用 看下面 ...
- [OC Foundation框架 - 19] 练习遇到的Bugs
1.没有权限读取文件夹 The file “Homework2” couldn’t be opened because you don’t have permission to view it. ...
- Umbraco中的ModelBuilder
Umbraco中的ModelBuilder有以下几种形式 Pure Live models Dll models LiveDll models AppData models LiveAppData m ...
- hadoop 2.0 详细配置教程
http://www.cnblogs.com/scotoma/archive/2012/09/18/2689902.html
- ThindPad x230 无法U盘启动
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- NSMutableAttributedString iOS 在UILabel显示不同的字体和颜色(转)
在项目开发中,我们经常会遇到在这样一种情形:在一个UILabel 使用不同的颜色或不同的字体来体现字符串,在iOS 以后我们可以很轻松的实现这一点,官方的API 为我们提供了UILabel类的attr ...
- ios基础知识
1获取系统语言设置 NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; NSArray *languages = ...
- 数据持久化(五)之CoreData
@简单的说,Core Data就是能够存储到磁盘的对象图,[...]Core Data能够帮我们做非常多任务作.它能够作为软件的整个模型层. 它不只在磁盘上存储数据.也把我们须要的数据对象读取到内存中 ...
- AIR 程序开发系列 之五 保存数据的几种方式
Local SharedObject 这种方法比较简单方便的保存少的数据到到设备中.你不用自己去管理这些数据,设备会自动管理他. SharedObject 在 flash.net 包中,继承自Even ...