5.3使用Routes
注册Area Route
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
AreaRoute冲突
如何处理冲突
抛出异常
处理方法,使用NameSpace
route.MapRoute{
“Default”,
“{controller}/{action}/{id}”,
new {controller=“Home”,action=“Index”,id=“”),
new [] {“AreaDemoWeb.Controllers”}
}
捕获所有参数
让Route匹配任意多参数
routes.MapRoute(“catchallroute”,”query/{query-name}/{*extrastuff}”,
new QueryRouteHandler));
URL *extrastuff
/query/select/a/b/c “a/b/c”
/query/select/a/b/c/ “a/b/c”
/query/select “”(route仍然可以匹配)
全部匹配到一个参数上
停止匹配和忽略匹配
Route.add(new Route("{resource}.axd/{*pathinfo}",
new StopRoutingHandler())};
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
调试路由信息
使用 Routing Debugger
http://cde.hacked.com/mvc-1.0/RouteDebug-binary.zip
Protected void Application_Start(){
RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}
注册Area Route
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
AreaRoute冲突
如何处理冲突
抛出异常
处理方法,使用NameSpace
route.MapRoute{
“Default”,
“{controller}/{action}/{id}”,
new {controller=“Home”,action=“Index”,id=“”),
new [] {“AreaDemoWeb.Controllers”}
}
捕获所有参数
让Route匹配任意多参数
routes.MapRoute(“catchallroute”,”query/{query-name}/{*extrastuff}”,
new QueryRouteHandler));
URL *extrastuff
/query/select/a/b/c “a/b/c”
/query/select/a/b/c/ “a/b/c”
/query/select “”(route仍然可以匹配)
全部匹配到一个参数上
停止匹配和忽略匹配
Route.add(new Route("{resource}.axd/{*pathinfo}",
new StopRoutingHandler())};
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
调试路由信息
使用 Routing Debugger
http://cde.hacked.com/mvc-1.0/RouteDebug-binary.zip
Protected void Application_Start(){
RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}
发表评论
-
10.2Asp.net MVC各层使用TDD方式
2011-05-01 12:09 775Asp.net MVC各层使用TDD方式 Asp.net M ... -
10.1TDD简介
2011-04-30 23:09 534MVC中的测试驱动开发 为什么需要TDD TDD的由来 它 ... -
9、MVC程序安全限定
2011-04-29 22:14 1787常见网络安全攻击隐患 针对Asp.net MVC防御体系 安 ... -
8.2ASP.NET MVC2使用Ajax类库实例
2011-04-29 13:05 896ASP.NET MVC2使用Ajax类库实例 .net fo ... -
8.1Ajax类库介绍
2011-04-28 09:12 857在ASP.NET MVC中使用 -Microsoft ASP. ... -
7.2自定义开发Filter
2011-04-27 16:04 597Custom Filters ➤IAuthorization ... -
7.1Filter的使用
2011-04-26 22:20 479Filter的使用 -对Action的附加说明 Asp.n ... -
6.3Action的调用与属性
2011-04-26 09:43 646Action的调用与属性 1、唤起Action R ... -
6.2ActionResult的使用
2011-04-25 19:14 653ActionResult public abstract c ... -
6.1Controller类的基本构成
2011-04-25 09:17 642关于Controller Controller是什么? C ... -
5.6在Webform中使用routing
2011-04-23 22:48 635在Webform中使用routing 在Asp.net 4中使 ... -
5.5URL和Action匹配的秘密
2011-04-22 09:11 869Routes是如何把URL映射为Action -请求路由管道 ... -
5.4使用routing生成URL
2011-04-21 11:05 569使用routing生成URL URL生成器概述 1、质询每个 ... -
5.2Routes匹配URL的工作方式
2011-04-19 08:55 827URL的匹配规则 -site/{controller}/{ac ... -
5.1Url和Routes介绍
2011-04-17 12:05 6235.1Url和Routes介绍 关于Urls -域名好记好拼 ... -
4、View引擎介绍
2011-04-16 22:03 620View引擎介绍 Request =>Routing= ... -
3、HtmlHelper类(续)
2011-04-16 13:41 622HtmlHelper类(续) Html.TextArea 用 ... -
2、HtmlHelper类
2011-04-15 22:33 1072HtmlHelper类 <%Html. MVC1 & ... -
1、View层
2011-04-15 09:06 604ViewDataDictionary类 View 负责输出 ...
相关推荐
5.3 Testing Routes in MVC 5.4 Storing Information in Memory 5.5 Manipulating Files 6 Enhancing Views with HTML Helpers and Master Pages 6.1 Making Our Site Presentable with HTML Helpers 6.2 ...
从Laravel 5.3+开始,API路径被放入了routes/api.php中。我们绝大多数的路径其实都会在web.php中定义,因为在web.php中定义的路径默认有CSRF保护,而API路径默认没有CSRF保护。在Laravel官网文档中写到:/p> Any ...
// Lily provides building blocks for applications like routing$ handler = new Lily \ Application \ RoutedApplication ([ // Define your routes as plain arrays 'routes' => [[ 'GET' , '/' , 'Hello world'
嵌套子路由的关键属性是children,children也是一组路由,相当于前面讲到的routes,children可以像routes一样的去配置路由数组。每一个子路由里面可以嵌套多个组件,子组件又有路由导航和路由容器。 父路由的地址/要...
前言 大家可能没有注意到, 在 Laravel 4 以及更老版本中, 路由逻辑是性能上的一个瓶颈–特别是对于有很多路由...在 Laravel 5.2 的routes.php中我们可以看到路由被分割成两个路由群组:web和api,这样做的原因是基于
通过一个名称来标识一个路由显得更方便一些,特别是在链接一个路由,或者是执行一些跳转的时候,通过路由的名称取代路径地址直接使用。像这种命名路由的方式,无论path多长、多烦琐,都能直接通过name来引用,十分...
5.3或以上 发牌 目前,我没有许可该作品。 它具有Bonfire项目的一些代码,并保留了其许可权。 未来的计划 缓存路线。 安装 只需使用相同的文件夹结构将文件复制到您的服务器即可。 如果开发人员以前安装了作为HMVC...
5.3 Sharding Chapter 6: NewsWatcher App Development 6.1 Create the Database and Collection 6.2 Data Model Document Design 6.3Trving Out Some Queries 5.4Indexing Policy 6.5Moving On Chapter 7: DevOps ...
概述Vrata(俄语为“ gates”)是使用Lumen框架在PHP7中实现的简单API网关介绍性博客文章,要求和依赖性PHP> = 7.0 流明5.3 食尸鬼6 Laravel护照(与) Memcached(用于请求限制)作为Docker容器运行理想情况下,您...
Fault Domains Statements 1.6.Layer-2 and Layer-3 Support Statements 1.7.Multicast 1.8.Unicast 1.9.Jumbo Frames 1.10.IPv6 support 1.11.TCP/IP Stacks 1.12.Static Routes 1.13.NSX 1.14.Flow Control 1.15....
Section 5.3. Basic Goals of NIC Initialization NIC初始化的基本目标 Section 5.4. Interaction Between Devices and Kernel 设备与内核的交互 Section 5.5. Initialization Options 初始化选项 Section 5.6. ...