本文整理汇总了C#中RouteCollection.Ignore方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.Ignore方法的具体用法?C# RouteCollection.Ignore怎么用?C# RouteCollection.Ignore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.Ignore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register404Route
/// <summary>
/// Registers C1's 404 route that catches all requests.
/// This method should be called only after all other routes are registered.
/// </summary>
public static void Register404Route(RouteCollection routes)
{
// Ignoring routes that shouldn't be caught by 404 handler
routes.Ignore("Renderers/{*pathInfo}");
routes.Ignore("{*all_css_aspx}", new { all_css_aspx = @".*\.css.aspx(/.*)?" });
routes.Add("c1 404 route", new PageNotFoundRoute());
}
示例2: RegisterRoutes
internal static void RegisterRoutes(RouteCollection routes)
{
if (routes != null)
{
Log.Information("Registering routes.");
routes.Ignore("{resource}.axd");
routes.Ignore("{*url}", new { url = @".*\.asmx(/.*)?" });
routes.MapPageRoute("DefaultRoute", "", "~/SignIn.aspx");
routes.MapPageRoute("Reporting", "Reports/{path}", "~/Reports/ReportMaster.aspx");
routes.MapPageRoute("Modules", "Modules/{*path}", "~/Modules/Default.aspx");
}
}
示例3: IgnoreIgnoreRoutes
public void IgnoreIgnoreRoutes()
{
var routeCollection = new RouteCollection();
routeCollection.Ignore("IgnoreMe");
var filter = new IgnoreUnsupportedRoutesFilter();
Assert.IsFalse(filter.AllowRoute(routeCollection[0]));
}
示例4: RegisterRoutes
// register routes with routing system.
private static void RegisterRoutes(RouteCollection routes)
{
// note: the order in which routes are registered is important.
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("Error", "error", "~/Error.aspx");
routes.MapPageRoute("Login", "login", "~/WebAuth/Login.aspx");
routes.MapPageRoute("Logout", "logout", "~/WebAuth/Logout.aspx");
routes.MapPageRoute("Shop", "shop", "~/WebShop/Shopping.aspx");
routes.MapPageRoute("Products", "shop/products", "~/WebShop/Products.aspx");
routes.MapPageRoute("Product", "shop/products/{productid}", "~/WebShop/Product.aspx");
routes.MapPageRoute("Search", "shop/search", "~/WebShop/Search.aspx");
routes.MapPageRoute("Cart", "shop/cart", "~/WebShop/Cart.aspx");
routes.MapPageRoute("Checkout", "shop/checkout", "~/WebShop/Checkout.aspx");
routes.MapPageRoute("Admin", "admin", "~/WebAdmin/Admin.aspx");
routes.MapPageRoute("Orders", "admin/members/orders", "~/WebAdmin/Orders.aspx");
routes.MapPageRoute("Order", "admin/members/{memberid}/orders", "~/WebAdmin/Order.aspx");
routes.MapPageRoute("Details", "admin/members/{memberid}/orders/{orderid}/details", "~/WebAdmin/OrderDetails.aspx");
routes.MapPageRoute("Member", "admin/members/{memberid}", "~/WebAdmin/Member.aspx");
routes.MapPageRoute("Members", "admin/members", "~/WebAdmin/Members.aspx");
routes.MapPageRoute("Default", "", "~/Default.aspx");
}
示例5: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
routes.Ignore("*.img");
}
示例6: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.MapPageRoute(
"SalesSummaryRoute",
"SalesReportSummary/{year}",
"~/SalesSummary.aspx",
true,
new RouteValueDictionary { }
);
var route = routes.MapPageRoute(
"SalesRoute",
"SalesReport/{locale}/{year}",
"~/Sales.aspx",
true,
new RouteValueDictionary { }
);
route.RouteHandler = new PageRouteHandler("~/Sales.aspx");
routes.MapPageRoute(
"ExpensesRoute",
"ExpenseReport/{locale}/{year}/{*extraInfo}",
"~/Expenses.aspx",
true,
new RouteValueDictionary { },
new RouteValueDictionary { { "extraInfo", new CharactersConstraint() } }
);
}
示例7: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.RouteExistingFiles = false;
routes.IgnoreRoute("WebApp/{*pathInfo}");
routes.Ignore("favicon.ico");
routes.MapRoute("", "{*mapUri}", new { controller = "App", action = "Render" });
}
示例8: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
// Нормализация виртуальных путей для оптимизации SEO
routes.AppendTrailingSlash = true;
routes.LowercaseUrls = true;
// Игнорирование путей
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Ignore("css/{*pathInfo}");
routes.Ignore("js/{*pathInfo}");
routes.Ignore("img/{*pathInfo}");
routes.Ignore("error/forbidden.html");
routes.Ignore("error/gatewaytimeout.html");
routes.Ignore("error/serviceunavailable.html");
routes.Ignore("humans.txt");
// Включение маршрутов по аттрибутам
routes.MapMvcAttributeRoutes();
// Данный маршрут нужен только для системы логирования Elmah.MVC.
// У этой системы есть баг, из-за которого некоторые 404 и 500 ошибки не логируются без
// регистрации такого маршрута.
// https://github.com/alexbeletsky/elmah-mvc/issues/60
// https://github.com/RehanSaeed/ASP.NET-MVC-Boilerplate/issues/8
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
示例9: RegisterRoutes
private void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("User routes", "{username}", "~/Routes.aspx", true, null,
new RouteValueDictionary { { "username", "[a-zA-Z].*" } });
routes.MapPageRoute("Route map", "{username}/{routeId}", "~/Map.aspx");
}
示例10: RegisterRoutes
/// <summary>
/// </summary>
/// <param name="routes"></param>
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
#if DEBUG // Mapeia as rotas customizadas para tela default.
routes.MapPageRoute("Documentation_Login", "", "~/Views/Documentation/Login.html");
routes.MapPageRoute("Documentation_Sandbox", "Sandbox/", "~/Views/Documentation/Sandbox.html");
#endif
}
示例11: IgnoredRoutesDoNotThrowAnException
public void IgnoredRoutesDoNotThrowAnException()
{
var config = new Mock<IConfiguration>();
var routeCollection = new RouteCollection();
routeCollection.Ignore("IgnoreMe");
var routeFilter = new MvcRouteFilter(config.Object, routeCollection);
Assert.DoesNotThrow(() => routeFilter.AllowRoute(routeCollection[0]));
}
示例12: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
foreach (IRouteRegistrar routeRegistrar in GetRouteRegistrars())
{
routeRegistrar.RegisterRoute(routes);
}
}
示例13: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
//friendly url
var settings = new FriendlyUrlSettings
{
AutoRedirectMode = RedirectMode.Permanent,
ResolverCachingMode = ResolverCachingMode.Dynamic
};
routes.EnableFriendlyUrls(settings);
//ignore routes
routes.Ignore("{resource}.axd/{*pathInfo}");
// routs
routes.MapPageRoute("EditArticle", "User/Articles/Edit/{id}",
"~/Managements/Articles/Edit.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" } });
routes.MapPageRoute("DeleteArticle", "User/Articles/Delete/{id}",
"~/Managements/Articles/Delete.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" } });
routes.MapPageRoute("ShowArticles", "User/Articles/Show",
"~/Managements/Articles/Default.aspx", true, null, null);
routes.MapPageRoute("InsertArticle", "User/Articles/Insert",
"~/Managements/Articles/Insert.aspx", true, null, null);
routes.MapPageRoute("DeleteComment", "Forum/Topic/{topicId}/post/Comments/{id}",
"~/Managements/Comments/Delete.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" }, { "topicId", @"\d+" } });
routes.MapPageRoute("AddComment", "Forum/Topic/{topicId}/post/{postId}/NewComment",
"~/Managements/Comments/Insert.aspx", true, null, new RouteValueDictionary { { "postId", @"\d+" }, { "topicId", @"\d+" } });
routes.MapPageRoute("DeletePost", "Forums/Topic/{topicId}/Posts/Delete/{id}",
"~/Managements/ForumPost/Delete.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" }, { "topicId", @"\d+" } });
routes.MapPageRoute("EditPost", "Forums/Topic/{topicId}/Posts/Edit/{id}",
"~/Managements/ForumPost/Edit.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" }, { "topicId", @"\d+" } });
routes.MapPageRoute("ChangePass", "User/ChangePass", "~/Account/ChangePass.aspx", true);
routes.MapPageRoute("Confirm", "Confirm", "~/Account/Confirm.aspx", true);
routes.MapPageRoute("login", "Login", "~/Account/Login.aspx", true);
routes.MapPageRoute("ShowPost", "Forums/Topic/{topicId}/Posts", "~/Managements/ForumPost/Default.aspx", true,
null, new RouteValueDictionary { { "topicId", @"\d+" } });
routes.MapPageRoute("ShowMsg", "User/Conversation/{id}/Messages", "~/Account/ShowMessages.aspx", true,
new RouteValueDictionary { { "id", "" } }, new RouteValueDictionary { { "id", @"\d+" } });
routes.MapPageRoute("EditForum", "Forum/Edit/{id}", "~/Managements/Forum/Edit.aspx", true, null,
new RouteValueDictionary { { "id", @"\d+" } });
routes.MapPageRoute("DeleteForum", "Forum/Delete/{id}", "~/Managements/Forum/Delete.aspx", true, null,
new RouteValueDictionary { { "id", @"\d+" } });
routes.MapPageRoute("InsertForum", "Forum/Insert", "~/Managements/Forum/Insert.aspx", true);
routes.MapPageRoute("DeleteTopic", "Forums/{forumId}/Topics/Delete/{id}",
"~/Managements/ForumTopic/Delete.aspx", true, null,
new RouteValueDictionary { { "id", @"\d+" }, { "forumId", @"\d+" } });
routes.MapPageRoute("EditTopic", "Forums/{forumId}/Topics/Edit/{id}/{fromPost}",
"~/Managements/ForumTopic/Edit.aspx", true, new RouteValueDictionary { { "fromPost",0 } }, new RouteValueDictionary { { "id", @"\d+" }, { "forumId", @"\d+" }, { "fromPost", @"\d+" } });
routes.MapPageRoute("CreateTopic", "Forums/{id}/Topics/NewTopic", "~/Managements/ForumTopic/Insert.aspx", true);
routes.MapPageRoute("Profile", "Profile/{id}", "~/Account/PublicProfile.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" } });
routes.MapPageRoute("MainForum", "Forum", "~/Managements/Forum/Default.aspx", true);
routes.MapPageRoute("SubForums", "Forums/{id}", "~/Managements/ForumTopic/Default.aspx", true, null, new RouteValueDictionary { { "id", @"\d+" } });
}
示例14: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
// Define uma rota padrão para qualquer controller e suas actions.
routes.MapRoute("Controllers", "data/{controller}/{action}/");
// Mapeia as rotas customizadas para tela default.
routes.MapPageRoute("Default", "", "~/Views/Default.html");
}
示例15: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Ignore("{rssname}.rss");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}