当前位置: 首页>>代码示例>>C#>>正文


C# RouteCollection.Root方法代码示例

本文整理汇总了C#中RouteCollection.Root方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.Root方法的具体用法?C# RouteCollection.Root怎么用?C# RouteCollection.Root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RouteCollection的用法示例。


在下文中一共展示了RouteCollection.Root方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Root();
            routes.MapRoute("ClientRoute",
                        "tasks/{year}/{month}/{day}",
                        new { controller = "Home", action = "Index" },
                        new { httpMethod = new HttpMethodConstraint("GET") });
            routes.MapRoute("GetTasksByDate",
                        "api/tasks/{year}/{month}/{day}",
                        new {controller = "Tasks", action = "Index"},
                        new {httpMethod = new HttpMethodConstraint("GET")});
            routes.Resource("tasks", "api");
        }
开发者ID:kibiluzbad,项目名称:Ogum,代码行数:15,代码来源:Routes.cs

示例2: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "PostsPaged",
                "posts/{itemsPerPage}/{pageNumber}",
                new { controller = "Posts", action = "Index" },
                new { itemsPerPage = "\\d+", pageNumber = "\\d+", httpMethod = new HttpMethodConstraint("GET") }
                );
            
            routes.Root("Posts");

            routes.MapRoute(
                "PostPaginated", // Route name
                "Posts/{itemsPerPage}/{pageNumber}", // URL with parameters
                new {controller = "Posts", action = "Index"},
                new
                    {
                        itemsPerPage = @"\d+",
                        pageNumber = @"\d+",
                        httpMethod = new HttpMethodConstraint("GET")
                    });

            routes.MapRoute(
                "CommentPost", // Route name
                "posts/{slug}/comment", // URL with parameters
                new {controller = "Posts", action = "Comment"}, // Parameter defaults
                new {slug = @"[\w\-]+"}
                );

            routes.MapRoute(
                "RecentPosts", // Route name
                "RecentPosts", // URL with parameters
                new {controller = "Posts", action = "Last"},
                new {httpMethod = new HttpMethodConstraint("GET")}
                );

            routes.Resource("Posts");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults
                );
        }
开发者ID:kibiluzbad,项目名称:Xango.Blog,代码行数:46,代码来源:Global.asax.cs

示例3: MappingRoot

 public void MappingRoot()
 {
     var routes = new RouteCollection();
     routes.MapRoot("Patients", "Index");
     Assert.AreEqual("Patients", routes.Root().Values["controller"]);
     Assert.AreEqual("Index", routes.Root().Values["action"]);
 }
开发者ID:bbyars,项目名称:Castle.MonoRail.Routing,代码行数:7,代码来源:RouteCollectionExtensionsTest.cs


注:本文中的RouteCollection.Root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。