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/ ...
随机推荐
- 【Linux 命令】Linux系统下强制用户下线——who,pkill
[日期]2014年11月18日 [平台]Centos 6.5 [工具]who pkill [步骤] 1)准备工作 以root身份登录. 2)执行who命令,查看有哪些用户已登录到当前主机
- poj 1704 阶梯博弈
转自http://blog.sina.com.cn/s/blog_63e4cf2f0100tq4i.html 今天在POJ做了一道博弈题..进而了解到了阶梯博弈...下面阐述一下我对于阶梯博弈的理解. ...
- SQL2008-功能设置
1.问题:修改表字段类型后,无法保存答:工具—选项—Designers—表设计器和数据库设计器—阻止保存要求重新创建表的更改前的勾去掉. 2.问题: 编写SQL语句的地方怎么自动换行答:工具-> ...
- iOS: ARC和非ARC下使用Block属性的问题
1. Block的声明和线程安全 Block属性的声明,首先需要用copy修饰符,因为只有copy后的Block才会在堆中,栈中的Block的生命周期是和栈绑定的,可以参考之前的文章(iOS: 非AR ...
- 转载 DevOps的基本原则与介绍
转载原地址: http://www.cnblogs.com/wintersun/p/3339047.html DevOps的基本原则与介绍 DevOps这个术语是developer与operatio ...
- loadmore
实例点击 loadmore.js /* * loadmore.js require jQuery,artTemplate * Butterfly 2013.08.28 */ define(['../u ...
- jquery-ui 之Sortable详解
<div class="aaa"> <ul id="sortable"> <li id="test">I ...
- Handlebar
1.Handlebar中文网: http://www.ghostchina.com/introducing-the-handlebars-js-templating-engine/ 2.http:// ...
- Activity详解
Activity是android应用的重要组成单元之一(另外3个是Service,BroadcastReceiver和ContentProvider).实际应用包含了多个Activity,不同的Act ...
- CC_CALLBACK原理及应用
http://my.oschina.net/u/555701/blog/219844 c++ 11 基础 : std::function 类模版 std::function是一种通用.多态的函 ...