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


C# HttpRouteCollection.IgnoreRoute方法代码示例

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


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

示例1: RegisterRoutes

        public static void RegisterRoutes(HttpRouteCollection routes)
        {
            routes.IgnoreRoute("Html", "{whatever}.html/{*pathInfo}");
            routes.IgnoreRoute("FilesRoute", "app/{*pathInfo}");

            routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "{controller}/{action}/{id}",
                    defaults: new { controller = "Default",
                        action = "Get", id = RouteParameter.Optional }
                );
        }
开发者ID:pveerath,项目名称:BeanCache,代码行数:12,代码来源:RouteConfig.cs

示例2: IgnoreRouteInternalNeverMatchesUrlGeneration

        public void IgnoreRouteInternalNeverMatchesUrlGeneration()
        {
            // Arrange
            HttpRouteCollection routes = new HttpRouteCollection();
            IHttpRoute route = routes.IgnoreRoute("Foo", "SomeRouteTemplate");

            // Act
            IHttpVirtualPathData vpd = route.GetVirtualPath(new HttpRequestMessage(HttpMethod.Get, "SomeRouteTemplate"), null);

            // Assert
            Assert.Null(vpd);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:12,代码来源:HttpRouteCollectionExtensionsTest.cs

示例3: IgnoreRouteWithConstraints

        public void IgnoreRouteWithConstraints()
        {
            // Arrange
            HttpRouteCollection routes = new HttpRouteCollection();
            var constraints = new { Foo = "DefaultFoo" };

            // Act
            routes.IgnoreRoute("SomeRouteName", "SomeRouteTemplate", constraints);

            // Assert
            HttpRoute route = Assert.Single(routes.Cast<HttpRoute>());
            Assert.NotNull(route);
            Assert.Equal("SomeRouteTemplate", route.RouteTemplate);
            Assert.IsType<StopRoutingHandler>(route.Handler);
            Assert.True(route.Defaults.Count == 0);
            Assert.Single(route.Constraints);
            Assert.Equal("DefaultFoo", route.Constraints["Foo"]);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:18,代码来源:HttpRouteCollectionExtensionsTest.cs

示例4: IgnoreRouteWithNullUrlThrows

        public void IgnoreRouteWithNullUrlThrows()
        {
            // Arrange
            HttpRouteCollection routes = new HttpRouteCollection();

            // Act & Assert
            Assert.ThrowsArgumentNull(
                delegate { routes.IgnoreRoute("foo", null); },
                "routeTemplate");
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:10,代码来源:HttpRouteCollectionExtensionsTest.cs

示例5: IgnoreRouteWithNullRouteNameThrows

        public void IgnoreRouteWithNullRouteNameThrows()
        {
            // Arrange
            HttpRouteCollection routes = new HttpRouteCollection();

            // Act & Assert
            Assert.ThrowsArgumentNull(
                delegate { routes.IgnoreRoute(null, "foo"); },
                "routeName");
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:10,代码来源:HttpRouteCollectionExtensionsTest.cs


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