本文整理汇总了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 }
);
}
示例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);
}
示例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"]);
}
示例4: IgnoreRouteWithNullUrlThrows
public void IgnoreRouteWithNullUrlThrows()
{
// Arrange
HttpRouteCollection routes = new HttpRouteCollection();
// Act & Assert
Assert.ThrowsArgumentNull(
delegate { routes.IgnoreRoute("foo", null); },
"routeTemplate");
}
示例5: IgnoreRouteWithNullRouteNameThrows
public void IgnoreRouteWithNullRouteNameThrows()
{
// Arrange
HttpRouteCollection routes = new HttpRouteCollection();
// Act & Assert
Assert.ThrowsArgumentNull(
delegate { routes.IgnoreRoute(null, "foo"); },
"routeName");
}