MVC 路由检测组件 Routing Debugger
组件下载地址 haacked.com
1、在mvc项目中引入组件
2、配置route规则
public static void RegisterRoutes(RouteCollection routes)
{
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//忽略About页面,不能将它已到mapRoute后面,改方法不是有Route组件提供是System.Web.Mvc下的方法
//routes.IgnoreRoute("Home/About"); routes.MapRoute(
"Default", // 路由名称
"{controller}/{action}/{id}", // 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // 参数默认值
new { controller=@"^\w+",action=@"^\w+"}
); routes.MapRoute(
"Filter", // 路由名称
"{controller}/{action}/{id}", // 带有参数的 URL
new { controller = "Filter", action = "Index", id = UrlParameter.Optional }, // 参数默认值
new { controller = @"^\w+", action = @"^\w+" }
); routes.MapRoute(
"car",
"Car/{make}/{pro}",
new {controller="Car",action="Index",id=}
); routes.MapRoute(
"Archive",
"Archive/{date}",
new { controller = "blog", action = "Archive" },
new {date=@"^\d{4}-\d{2}-\d{2}" } ); routes.MapRoute(
"Book",
"Book/Add/{name}",
new { controller = "Book", action = "Add" },
new { HttpMethod="Post"}
); routes.MapRoute(
"Product",
"Product/{*value}",//*表示匹配一切内容
new {controller="Product",action="Index" }
); /*Dictionary<string, object> defaultRout = new Dictionary<string, object>();
defaultRout["action"] = "Index";
defaultRout["id"] = 0; RouteValueDictionary defaultRouteValue = new RouteValueDictionary(defaultRout); RouteValueDictionary constrainRouteValue = new RouteValueDictionary();
constrainRouteValue["controller"] = @"\w+";
constrainRouteValue["id"] = @"\d+"; Route route = new Route("{controller}/{action}/{id}", defaultRouteValue, constrainRouteValue, new MvcRouteHandler());*/
}
3、在Global.asax.cs代码中写入
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
//设为true表示url指向磁盘上的物理文件也会进行url routing处理,例如一个普通的html页面
RouteTable.Routes.RouteExistingFiles = true;
RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}

MVC 路由检测组件 Routing Debugger的更多相关文章
- asp.net mvc 路由检测工具
初学mvc,路由搞不清楚,可以通过一款插件 查看匹配的路由. 工具名<RouteDebugger> 可以在nuget中查询RouteDebugger后,安装.或者在控制台进行安装: pm& ...
- 返璞归真 asp.net mvc (2) - 路由(System.Web.Routing)
原文:返璞归真 asp.net mvc (2) - 路由(System.Web.Routing) [索引页] [源码下载] 返璞归真 asp.net mvc (2) - 路由(System.Web.R ...
- ASP.NET MVC 路由(一)
ASP.NET MVC路由(一) 前言 从这一章开始,我们即将进入MVC的世界,在学习MVC的过程中在网上搜索了一下,资料还是蛮多的,只不过对于我这样的初学者来看还是有点难度,自己就想看到有一篇引导性 ...
- Asp.Net MVC 3【URLs, Routing,and Areas】续
http://www.cnblogs.com/HuiTai/archive/2012/07/24/2597875.html 接着前面继续学习分享我们的路由. 现在我们把Global.asax文件里的R ...
- 【ASP.NET MVC系列】浅谈ASP.NET MVC 路由
ASP.NET MVC系列文章 [01]浅谈Google Chrome浏览器(理论篇) [02]浅谈Google Chrome浏览器(操作篇)(上) [03]浅谈Google Chrome浏览器(操作 ...
- MVC路由解析---MapRoute
文章引导 MVC路由解析---IgnoreRoute MVC路由解析---MapRoute MVC路由解析---UrlRoutingModule Area的使用 引言 前面我们讲了IgnoreRout ...
- ASP.NET路由[ASP.NET Routing]
ASP.NET路由[ASP.NET Routing] ASP.NET路由允许你在使用URL时不必匹配到网站中具体的文件,因为这个URL不必匹配到一个文件,你使用了描述用户行为且更容易被用户理解的URL ...
- MVC 路由介绍
我们新建一个ASP.NET MVC Web程序的时候,会生成一个Global.asax文件.如下: using System; using System.Collections.Generic; us ...
- MVC路由探寻,涉及路由的惯例、自定义片段变量、约束、生成链接和URL等
引子 在了解MVC路由之前,必须了解的概念是"片段".片段是指除主机名和查询字符串以外的.以"/"分隔的各个部分.比如,在http://site.com/Hom ...
随机推荐
- Luogu 2824 [HEOI2016/TJOI2016]排序
BZOJ 4552 挺妙的解法. 听说这题直接用一个桶能拿到$80 \ pts$ 发现如果是一个排列的话,要对这个序列排序并不好做,但是假如是$01$序列的话,要对一个区间排序还是很简单的. 发现最后 ...
- 8.View类
Basic Concepts 在Modle/View 结构中,View从Model中提取数据,并显示给用户.View显示数据的方式不一定与Model中数据排列方式相同,也可能与底层数据结构完 ...
- 按位操作符(Bitwise operators)
按位操作符(Bitwise operators) 将其操作数(operands)当作32位的比特序列(由0和1组成),而不是十进制.十六进制或八进制数值.例如,十进制数9,用二进制表示则为1001.按 ...
- SDUT 3377 数据结构实验之查找五:平方之哈希表
数据结构实验之查找五:平方之哈希表 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 给定的一组 ...
- 如何使用ArcPy
ArcPy可以很方便的通过脚本调用ArcGIS的各种函数和功能.在此简单介绍一下.方法包括两种,第一种是直接使用ArcGIS中的命令行,输入一句,执行一句:第二种是创建一个Python脚本,直接执行其 ...
- postgre-sql语法
//客户端查询 public void pgsearchclient(HttpContext context, string starttime, string endtime, int page, ...
- C# 三元运算
x=,y=; z=x>y? : 结果z= x=,y=; z=x>y? : 结果z=
- jQuery的选择器+实例
返回目录 jQuery的冒号选择器 表单 :input :text :password :radio :checkbox :submit :image :reset :button :file :h ...
- Service Fabric 注意事项
1. ActorTimer和ActorReminder会阻塞一个Actor的其他外部方法调用,即ActorTimer和ActorReminder内部就去未执行完毕之前,该Actor其他方法只能等待. ...
- ubuntu - 14.04,由于安装软件造成磁盘空间不足,无法登入Gnome解决办法!!
刚才安装了半天软件,最后出现磁盘空间不足的问题,刚开始我还以为ubuntu和我开玩笑,随后我重新启动它才发现真不是开玩笑,我已经进不去Gnome桌面了!!! 解决办法: 1,以root身份进入shel ...