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


C# HttpRouteCollection.MapHttpRoute方法代码示例

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


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

示例1: RegisterRoutes

 public static void RegisterRoutes(HttpRouteCollection routes)
 {
     routes.MapHttpRoute("BeersRoute", "beers/{id}", new { controller = "Beer" }); // this one is needed only because beers vs. 1 beer are separated into 2 controllers
     routes.MapHttpRoute("DefaultApi", "{controller}/{id}", new { id = RouteParameter.Optional });
     routes.MapHttpRoute("BreweryBeersRoute", "breweries/{id}/beers", new { controller = "BeersFromBrewery" });
     routes.MapHttpRoute("StyleBeersRoute", "styles/{id}/beers", new { controller = "BeersFromStyle" });
 }
开发者ID:AndreasKorn,项目名称:WebApi.Hal,代码行数:7,代码来源:RouteConfig.cs

示例2: RegisterRoutes

 private static void RegisterRoutes( HttpRouteCollection routes )
 {
     routes.MapHttpRoute( "Info", "", new { controller = "Game", action = "Info" } );
       routes.MapHttpRoute( "User", "User", new { controller = "User" } );
       routes.MapHttpRoute( "Game", "{action}", new { controller = "Game" } );
       routes.MapHttpRoute( "Default", "{controller}/{action}" );
 }
开发者ID:h2h,项目名称:HelloWorld,代码行数:7,代码来源:Global.asax.cs

示例3: RegisterRoutes

 public static void RegisterRoutes(HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
             name: "DefaultApi",
             routeTemplate: "docs/{id}",
             defaults: new { controller = "Default", id = RouteParameter.Optional }
         );
     routes.MapHttpRoute(
             name: "Default2Api",
             routeTemplate: "{controller}/{id}",
             defaults: new { controller = "Default", id = RouteParameter.Optional }
         );
 }
开发者ID:adhurwit,项目名称:SearchFabric,代码行数:13,代码来源:RouteConfig.cs

示例4: RegisterRoute

        static void RegisterRoute(HttpRouteCollection routes)
        {
            routes.MapHttpRoute(
                "get receipt",
                "receipt",
                new
                {
                    controller = "Receipt",
                    action = "BuildReceipt"
                },
                new
                {
                    httpMethod = new HttpMethodConstraint(HttpMethod.Post)
                });

            routes.MapHttpRoute("add promotion barcode",
                "promotions/{Type}",
                new
                {
                    controller = "Promotion",
                    action = "AddPromotionBarcode"
                },
                new
                {
                    HttpMethod = new HttpMethodConstraint(HttpMethod.Post)
                });

            routes.MapHttpRoute("get promotion barcodes",
                "promotions/{Type}",
                new
                {
                    controller = "Promotion",
                    action = "GetBarcodesByType"
                },
                new
                {
                    HttpMethod = new HttpMethodConstraint(HttpMethod.Get)
                });

            routes.MapHttpRoute("delete promotion barcodes",
                "promotions/{Type}",
                new
                {
                    controller = "Promotion",
                    action = "DeleteBarcodesByType"
                },
                new
                {
                    HttpMethod = new HttpMethodConstraint(HttpMethod.Delete)
                });
        }
开发者ID:XiaoVLiu,项目名称:PosApp-PWC,代码行数:51,代码来源:Bootstrap.cs

示例5: RegisterRoutes

        public static void RegisterRoutes(HttpRouteCollection routes)
        {
            routes.MapHttpRoute(
                name: "Home",
                routeTemplate: "",
                defaults: new { controller = "Home", action = "Index" }
            );

            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
开发者ID:paperoni,项目名称:web-api,代码行数:14,代码来源:WebApiRoutes.cs

示例6: Can_get_names_from_a_HttpRouteCollection

        public void Can_get_names_from_a_HttpRouteCollection()
        {
            var routes = new HttpRouteCollection();

            routes.MapHttpRoute("foo.show", "foo/{id}");
            routes.MapHttpRoute("foo.one.two", "foo/{one}/{two}");
            routes.MapHttpRoute("bar.show", "bar/{id}", defaults: new { id = RouteParameter.Optional });
            routes.MapHttpRoute("bar.one.two", "bar/{one}/{two}",
                defaults: new { one = RouteParameter.Optional, two = RouteParameter.Optional });
            routes.MapHttpRoute("constraint", "constraints/{id:int}", null, new { id = @"\d+" });

            var names = routes.GetNames();
            Assert.True(names.Count == 5);
        }
开发者ID:ritterim,项目名称:Supurlative,代码行数:14,代码来源:ExtensionTests.cs

示例7: ConfigureHttpRoutes

        private static void ConfigureHttpRoutes(HttpRouteCollection routes)
        {
            routes.MapHttpRoute(
                name: "Courses",
                routeTemplate: "",
                defaults: new { controller = "Courses" }
                );

            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
开发者ID:kanetz,项目名称:AspNetWebApiDemo,代码行数:14,代码来源:WebApiConfig.cs

示例8: RegisterRoutes

        public static void RegisterRoutes(HttpRouteCollection routes)
        {
            routes.MapHttpRoute(
                name: ProductsWithDetailsRouteName,
                routeTemplate: "api/products/details",
                defaults: new
                {
                    controller = "Products",
                    id = RouteParameter.Optional,
                    action = "Details"
                });

            routes.MapHttpRoute(
             name: ProductsSoldOutRouteName,
             routeTemplate: "api/products/{id}/mark-sold-out",
             defaults: new
             {
                 controller = "Products",
                 action = "MarkSoldOut"
             });

            routes.MapHttpRoute(
                name: ProductsRouteName,
                routeTemplate: "api/products/{id}",
                defaults: new
                {
                    controller = "Products", id = RouteParameter.Optional, action = "Default"
                });

            routes.MapHttpRoute(
               name: CustomerAddressesRouteName,
               routeTemplate: "api/customers/{id}/addresses",
               defaults: new
               {
                   controller = "Customers",
                   action = "AddressesForCustomer"
               });

            routes.MapHttpRoute(
                name: CustomersRouteName,
                routeTemplate: "api/customers/{id}",
                defaults: new
                {
                    controller = "Customers",
                    id = RouteParameter.Optional,
                    action = "Default"
                });
        }
开发者ID:benpriebe,项目名称:ServerRI,代码行数:48,代码来源:WebApiConfig.cs

示例9: Configure

 private void Configure(HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
     "DefaultApiWithId",
     "Api/TestDependency",
     new { controller = "TestDependency" });
 }
开发者ID:Zero1991,项目名称:Topshelf.Integrations,代码行数:7,代码来源:TopshelfWebApiNinjectTests.cs

示例10: RegisterRoutes

        /// <summary>
        /// Routing registration.
        /// </summary>
        /// <param name="routes">The Http routes</param>
        public static void RegisterRoutes(HttpRouteCollection routes)
        {
            routes.MapHttpRoute(
                name: "AddWord",
                routeTemplate: "AddWord/{word}",
                defaults: new {controller = "Default", action = "AddWord"},
                constraints: new {}
                );

            routes.MapHttpRoute(
                name: "Count",
                routeTemplate: "Count",
                defaults: new {controller = "Default", action = "Count"},
                constraints: new {}
                );
        }
开发者ID:bobjac,项目名称:service-fabric-dotnet-getting-started,代码行数:20,代码来源:RouteConfig.cs

示例11: RegisterRoute

        static void RegisterRoute(HttpRouteCollection routes)
        {
            routes.MapHttpRoute(
                "get receipt",
                "receipt",
                new
                {
                    controller = "Receipt",
                    action = "BuildReceipt"
                },
                new
                {
                    httpMethod = new HttpMethodConstraint(HttpMethod.Post)
                });

            routes.MapHttpRoute(
                "create promotions",
                "promotions/{promotionType}",
                new
                {
                    controller = "Promotion",
                    action = "CreatePromotion"
                },
                new
                {
                    httpMethod = new HttpMethodConstraint(HttpMethod.Post)
                });

            routes.MapHttpRoute(
                "get promotion barcodes",
                "promotions/{promotionType}",
                new
                {
                    controller = "Promotion",
                    action = "GetPromotion"
                },
                new
                {
                    httpMethod = new HttpMethodConstraint(HttpMethod.Get)
                });

            routes.MapRoute(
                "promotions/{promotionType}",
                "Promotion",
                "DeletePromotion",
                HttpMethod.Delete);
        }
开发者ID:yanpei,项目名称:PosMachine,代码行数:47,代码来源:Bootstrap.cs

示例12: RegisterRoutes

 public static void RegisterRoutes(HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
         name: "Leases",
         routeTemplate: "leases/{resource}/{leaseId}",
         defaults: new { controller = "Leases", resource = RouteParameter.Optional, leaseId = RouteParameter.Optional }
         );
 }
开发者ID:yvesgoeleven,项目名称:CodeDAzure.ServiceFabric,代码行数:8,代码来源:RouteConfig.cs

示例13: RegisterRoutes

 internal static void RegisterRoutes(HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
         name: "DefaultApi",
         routeTemplate: "api/{controller}/{id}",
         defaults: new { id = RouteParameter.Optional }
     );
 }
开发者ID:zhangxd6,项目名称:dartshooting,代码行数:8,代码来源:RouteConfig.cs

示例14: Configure

 private static void Configure(HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
             "DefaultApiWithId", 
             "Api/{controller}/{id}", 
             new { id = RouteParameter.Optional }, 
             new { id = @"\d+" });
 }
开发者ID:Zero1991,项目名称:Topshelf.Integrations,代码行数:8,代码来源:Program.cs

示例15: ConfigureWebApiRoutes

 private static void ConfigureWebApiRoutes(HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
         "API Default",
         "api/{controller}/{id}",
         new { id = RouteParameter.Optional }
     );
 }
开发者ID:MatthewLymer,项目名称:TodoApp,代码行数:8,代码来源:Global.asax.cs


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