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 ...
随机推荐
- ZROI2018普转提day2t4
传送门 分析 考场上暴力水过好评... 然后我的st表查询似乎是log的,然后log三方跑的比log方快,qwq. 我们发现如果一个区间的最小值就是这个区间的gcd,则这个区间合法.所以我们二分区间长 ...
- java全栈day09----继承 抽象类
01继承的概述 在Java中,类的继承是指在一个现有类的基础上去构建一个新的类, 构建出来的新类被称作子类,现有类被称作父类在java中 继承如何来实用呢?举个例子 继承的定义格式和使用 *A:继承的 ...
- Android按钮单击事件处理的几种方法(Android学习笔记)
方法一:匿名内部类实现按钮事件处理 this.btnButton=(Button)super.findViewById(R.id.mybtn); this.btnButton.setOnClickLi ...
- EXCEL跨表比较两列,并填充新值背景
Sub FillNewToYellow() Dim dic Dim oldArr(), updatedArr() On Error Resume Next If Worksheets("ol ...
- 阿里开源混沌工程工具 ChaosBlade
https://github.com/chaosblade-io/chaosblade
- git 命令总结(转)
结构图: <1> Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一.新建代码库 # 在当前目录新建 ...
- 【转】C# 中的委托和事件(详解)
源地址:http://www.cnblogs.com/SkySoot/archive/2012/04/05/2433639.html
- CI框架源码学习笔记6——Config.php
接着上一节往下,我们这一节来看看配置类Config.php,对应手册内容http://codeigniter.org.cn/user_guide/libraries/config.html. clas ...
- (Python OpenGL)【4】Uniform变量 PyOpenGL
(Python OpenGL) 原文:http://ogldev.atspace.co.uk/www/tutorial05/tutorial05.html(英文) __author__ = " ...
- Python中的Numpy包
通过本次学习你可以掌握Numpy Numpy介绍(获取地址)更多Numpy函数 numpy的主要对象是同质多维数组.也就是在一个元素(通常是数字)表中,元素的类型都是相同的. numpy的数组类被成为 ...