本文整理汇总了C#中RouteCollection.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.Clear方法的具体用法?C# RouteCollection.Clear怎么用?C# RouteCollection.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.MapRoute("Start", "{controller}/{action}/{id}", new { controller = "StartPage", action = "Index", id = UrlParameter.Optional });
}
示例2: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
// Turns off the unnecessary file exists check
routes.RouteExistingFiles = true;
// Ignore text, html, files.
routes.IgnoreRoute("{file}.txt");
routes.IgnoreRoute("{file}.htm");
routes.IgnoreRoute("{file}.html");
routes.IgnoreRoute("Services/{*pathInfo}");
// Ignore axd files such as assets, image, sitemap etc
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Ignore the content directory which contains images, js, css & html
routes.IgnoreRoute("content/{*pathInfo}");
// Ignore the error directory which contains error pages
routes.IgnoreRoute("error/{*pathInfo}");
//Exclude favicon (google toolbar request gif file as fav icon which is weird)
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" });
//Actual routes of my application
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例3: ConfigureRoutes
public static RouteCollection ConfigureRoutes(RouteCollection routes) {
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}",
defaults: new {controller = "Customer", action = "Index", id = "1"});
return routes;
}
示例4: RegisterDummyRoutes
public static void RegisterDummyRoutes(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("ProductList", "Products", new { controller = "Product", action = "List" });
routes.MapRoute("ProductDetail", "Products/Detail/{id}", new { controller = "Product", action = "Detail", id = string.Empty });
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = string.Empty });
}
示例5: ConvertRoutesToLowercase
static void ConvertRoutesToLowercase(RouteCollection routes)
{
var lowercaseRoutes = routes.Select(r => new LowercaseRoute(r)).ToArray();
routes.Clear();
foreach (var route in lowercaseRoutes)
{
routes.Add(route);
}
}
示例6: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
MvcRoute.MappUrl("{controller}/{action}/{id}")
.WithDefaults(new { controller = "Home", action = "Index", id = "" })
.AddWithName("Default", routes);
}
示例7: Register
private static void Register(RouteCollection routes, IEnumerable<RouteItem> routeItems)
{
using (var @lock = routes.GetWriteLock())
{
routes.Clear();
foreach (var routeItem in routeItems.Where(r => !r.Disabled))
{
routes.Add(routeItem.Name, new RouteAdapter(routeItem));
}
}
}
示例8: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
// routes.IgnoreRoute("");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
ControllerDefault.MapDefault("file");
ControllerDefault.SetFactory<FileController>();
ControllerDefault.ChooseController = (ctx, controller) =>
{
if (controller.IndexOf("api", comparisonType: StringComparison.InvariantCultureIgnoreCase) >= 0)
return null; // new SymbolsController();
return new FileController();
};
}
示例9: Register
public static void Register(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpAttributeRoutes(c =>
{
c.ScanAssembly(Assembly.GetExecutingAssembly());
c.AutoGenerateRouteNames = true;
c.UseLowercaseRoutes = true;
c.AppendTrailingSlash = true;
c.RouteNameBuilder = specification =>
"api_" +
specification.ControllerName.
ToLowerInvariant() +
"_" +
specification.ActionName.
ToLowerInvariant();
});
routes.MapAttributeRoutes(c =>
{
c.ScanAssembly(Assembly.GetExecutingAssembly());
c.AutoGenerateRouteNames = true;
c.UseLowercaseRoutes = true;
c.AppendTrailingSlash = true;
c.RouteNameBuilder = specification =>
specification.ControllerName.
ToLowerInvariant() +
"_" +
specification.ActionName.ToLowerInvariant();
});
routes.MapRouteLowercase(
name: "default",
url: "{controller}/{action}/{id}",
defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional}
);
routes.MapRouteLowercase(
"homepage",
"",
new {controller = "Home", action = "Index"}
);
}
示例10: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favIcon}", new {favIcon = @"(.*)favicon.ico$"});
routes.IgnoreRoute("{*gifImages}", new {gifImages = @"(.*).gif$"});
routes.IgnoreRoute("{*pngImages}", new {pngImages = @"(.*).png$"});
routes.IgnoreRoute("{*jpgImages}", new {jpgImages = @"(.*).jpg$"});
routes.IgnoreRoute("{*css}", new {css = @"(.*).css$"});
routes.IgnoreRoute("{*js}", new {js = @"(.*).js$"});
routes.IgnoreRoute("{*txt}", new {txt = @"(.*).txt$"});
AreaRegistration.RegisterAllAreas();
routes.MapAttributeRoutes();
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = UrlParameter.Optional}
);
}
示例11: RegisterRoutes
/// <summary>
/// Register Pattern Lab specific routes
/// </summary>
/// <param name="routes">The existing route collection</param>
private static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
// Routes for assets contained as embedded resources
routes.Add("PatternLabAsset", new Route("{root}/{*path}", new RouteValueDictionary(new {}),
new RouteValueDictionary(new {root = "config|data|styleguide|templates", path = @"^(?!html).+"}),
new AssetRouteHandler()));
// Deprecated route for generating static output
routes.MapRoute("PatternLabBuilder", "builder/{*path}",
new {controller = "PatternLab", action = "Builder"},
new[] {"PatternLab.Core.Controllers"});
// Route for generating static output
routes.MapRoute("PatternLabGenerate", "generate/{*path}",
new { controller = "PatternLab", action = "Generate" },
new[] { "PatternLab.Core.Controllers" });
// Route styleguide.html
routes.MapRoute("PatternLabStyleguide", "styleguide/html/styleguide.html",
new {controller = "PatternLab", action = "ViewAll", id = string.Empty},
new[] {"PatternLab.Core.Controllers"});
// Route for 'view all' HTML pages
routes.MapRoute("PatternLabViewAll", string.Concat("patterns/{id}/", PatternProvider.FileNameViewer),
new {controller = "PatternLab", action = "ViewAll"},
new[] {"PatternLab.Core.Controllers"});
// Route for /patterns/pattern.escaped.html pages
routes.MapRoute("PatternLabViewSingleEncoded",
string.Concat("patterns/{id}/{path}", PatternProvider.FileExtensionEscapedHtml),
new {controller = "PatternLab", action = "ViewSingle", parse = true},
new[] {"PatternLab.Core.Controllers"});
// Route for /patterns/pattern.html pages
routes.MapRoute("PatternLabViewSingle",
string.Concat("patterns/{id}/{path}", PatternProvider.FileExtensionHtml),
new {controller = "PatternLab", action = "ViewSingle", masterName = "_Layout"},
new[] {"PatternLab.Core.Controllers"});
// Route for /patterns/pattern.mustache pages
routes.MapRoute("PatternLabViewSingleMustache",
string.Concat("patterns/{id}/{path}", PatternProvider.FileExtensionMustache),
new {controller = "PatternLab", action = "ViewSingle"},
new[] {"PatternLab.Core.Controllers"});
// Route for viewer page
routes.MapRoute("PatternLabDefault", "{controller}/{action}/{id}",
new {controller = "PatternLab", action = "Index", id = UrlParameter.Optional},
new[] {"PatternLab.Core.Controllers"});
}
示例12: RegisterRoutes
private void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.Clear();
// Root route
routes.MapRouteLowercase(
"Root",
"",
new { controller = "Home", action = "Stream" }
);
// Single Sign-On routes
routes.MapRouteLowercase(
"SSOAction",
"Auth/{action}",
new { controller = "Auth", action = "Register" }
);
// Back-end routes
routes.MapRouteLowercase(
"AdminHome",
"NSN",
new { controller = "Admin", action = "Index" }
);
routes.MapRouteLowercase(
"Admin",
"NSN/{action}/{id}",
new { controller = "Admin", action = "Index", id = UrlParameter.Optional },
new { id = @"^\d+$" }
);
// Front-end routes
routes.MapRouteLowercase(
"Stream",
"Stream",
new { controller = "Home", action = "Stream" }
);
routes.MapRouteLowercase(
"AjaxAction",
"Ajax/{action}",
new { controller = "Ajax" }
);
routes.MapRouteLowercase(
"Go",
"NSN/Go/To/{controller}/{action}"
);
routes.MapRouteLowercase(
"SearchAction",
"Search/{action}",
new { controller = "Search", action = "Result" }
);
routes.MapRouteLowercase(
"LinkAction",
"Links/{action}",
new { controller = "Link", action = "List" }
);
routes.MapRouteLowercase(
"MessageAction",
"Messages/{action}",
new { controller = "Message", action = "List" }
);
routes.MapRouteLowercase(
"PhotoAction",
"Photo/{photoid}/{action}",
new { controller = "Photo", action = "Show" },
new { photoid = @"^\d+$" }
);
routes.MapRouteLowercase(
"PhotoAlbumList",
"{uid}/Photos",
new { controller = "PhotoAlbum", action = "List" }
);
routes.MapRouteLowercase(
"PhotoAlbumAction",
"{uid}/Photos/{albumid}/{action}",
new { controller = "PhotoAlbum", action = "List" },
new { albumid = @"^\d+$" }
);
routes.MapRouteLowercase(
"FriendList",
"{uid}/Friends",
new { controller = "Friend", action = "List" }
);
routes.MapRouteLowercase(
"FriendAction",
"{uid}/Friends/{action}",
new { controller = "Friend", action = "List" }
);
routes.MapRouteLowercase(
"FeedAction",
"{uid}/Posts/{action}",
new { controller = "Feed", action = "Feeds" }
);
routes.MapRouteLowercase(
//.........这里部分代码省略.........
示例13: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes, bool OverrideRefresh) {
try {
string sKeyPrefix = "CarrotCakeCMS_";
if (!HasRegisteredRoutes || OverrideRefresh) {
List<string> listFiles = SiteNavHelper.GetSiteDirectoryPaths();
int iRoute = 0;
List<Route> lstRoute = new List<Route>();
//routes.Clear();
//only remove routes that are tagged as coming from the CMS
foreach (Route rr in routes) {
if (rr.DataTokens != null && rr.DataTokens["RouteName"] != null && rr.DataTokens["RouteName"].ToString().StartsWith(sKeyPrefix)) {
lstRoute.Add(rr);
}
}
foreach (Route rr in lstRoute) {
RouteTable.Routes.Remove(rr);
}
foreach (string fileName in listFiles) {
string sKeyName = sKeyPrefix + iRoute.ToString();
VirtualDirectory vd = new VirtualDirectory(fileName);
Route r = new Route(fileName.Substring(1, fileName.LastIndexOf("/")), vd);
if (r.DataTokens == null) {
r.DataTokens = new RouteValueDictionary();
}
r.DataTokens["RouteName"] = sKeyName;
routes.Add(sKeyName, r);
iRoute++;
}
HasRegisteredRoutes = true;
}
} catch (Exception ex) {
//assumption is database is probably empty / needs updating, so trigger the under construction view
if (DatabaseUpdate.SystemNeedsChecking(ex) || DatabaseUpdate.AreCMSTablesIncomplete()) {
routes.Clear();
HasRegisteredRoutes = false;
} else {
//something bad has gone down, toss back the error
throw;
}
}
}
示例14: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.Clear();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Account",
url: "account",
defaults: new { controller = "Website", action = "DisplayCustomerAccount" }
);
routes.MapRoute(
name: "AddAddress",
url: "account/addresses/{id}",
defaults: new { controller = "Website", action = "Addresses", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "DeleteAddress",
url: "account/deleteaddress/{addressID}",
defaults: new { controller = "Website", action = "DeleteAddress", addressID = UrlParameter.Optional }
);
routes.MapRoute(
name: "DonateCheckout",
url: "donate/{type}/{amount}",
defaults: new { controller = "Website", action = "DonationCheckout" }
);
routes.MapRoute(
name: "GetAddressList",
url: "shop/checkout/getaddresslist",
defaults: new { controller = "Website", action = "GetAddressList" }
);
routes.MapRoute(
name: "GetSelectedAddress",
url: "shop/checkout/getselectedaddress",
defaults: new { controller = "Website", action = "GetSelectedAddress" }
);
routes.MapRoute(
name: "EditMyDetails",
url: "account/editmydetails",
defaults: new { controller = "Website", action = "EditCustomerAccount" }
);
routes.MapRoute(
name: "OrderHistory",
url: "account/orderhistory",
defaults: new { controller = "WebSite", action = "OrderHistory" }
);
routes.MapRoute(
name: "Admn",
url: "admn/{action}/{id}",
defaults: new { controller = "Admn", action = "Home", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "SagePay",
url: "sagepay/{action}/{orderID}",
defaults: new { controller = "SagePay", action = "Home", orderID = UrlParameter.Optional }
);
routes.MapRoute(
name: "PayPal",
url: "paypal/{action}/{orderID}",
defaults: new { controller = "PayPal", action = "Home", orderID = UrlParameter.Optional }
);
routes.MapRoute(
name: "SecureTrading",
url: "securetrading/{action}/{orderID}",
defaults: new { controller = "SecureTrading", action = "Home", orderID = UrlParameter.Optional }
);
routes.MapRoute(
name: "Stripe",
url: "stripe/{action}/{orderID}",
defaults: new { controller = "Stripe", action = "Home", orderID = UrlParameter.Optional }
);
routes.MapRoute(
name: "Preview",
url: "preview",
defaults: new { controller = "Website", action = "Content" }
);
routes.MapRoute(
name: "Website",
url: "website/{action}/{id}",
defaults: new { controller = "Website", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Search",
url: "search/{keyword}",
defaults: new { controller = "Website", action = "Search", keyword = UrlParameter.Optional }
);
//.........这里部分代码省略.........
示例15: RegisterRoutes
public static void RegisterRoutes( RouteCollection routes )
{
if (routes == null) throw new ArgumentNullException( "routes" );
routes.Clear();
// Turns off the unnecessary file exists check
routes.RouteExistingFiles = true;
// Ignore text, html, files.
routes.IgnoreRoute( "{file}.txt" );
routes.IgnoreRoute( "{file}.htm" );
routes.IgnoreRoute( "{file}.html" );
// Ignore the assets directory which contains images, js, css & html
routes.IgnoreRoute( "assets/{*pathInfo}" );
// Ignore axd files such as assest, image, sitemap etc
routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" );
//Exclude favicon (google toolbar request gif file as fav icon which is weird)
routes.IgnoreRoute( "{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" } );
//// Routing config for the admin area
//routes.CreateArea(
// "admin",
// "Jumblist.Website.Areas.Admin.Controllers",
// routes.MapRoute(
// null,
// "admin/{controller}/{action}/{id}",
// new { controller = "Home", action = "Index", id = "" }
// )
//);
//// Routing config for the root (public) area
//routes.CreateArea(
// "root",
// "Jumblist.Website.Controllers",
// routes.MapRoute(
// null,
// "{controller}/{action}/{id}",
// new { controller = "Home", action = "Index", id = "" }
// )
//);
AreaRegistration.RegisterAllAreas();
routes.JumblistMapRoute(
"Post-Detail", // Route name
"post/{id}/{name}", // URL with parameters
new { controller = "Posts", action = "Detail", id = "", name = "" }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
routes.JumblistMapRoute(
"XMLSitemap", // Route name
"sitemap.xml", // URL with parameters
new { controller = "Posts", action = "XmlSiteMap" }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
routes.JumblistMapRoute(
"Rss-WithCategory", // Route name
"{controller}/{rssactionname}/{rssactionid}/{rssactioncategory}/rss", // URL with parameters
new { controller = "Posts", action = "Rss", rssactionname = "Index" }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
routes.JumblistMapRoute(
"Rss-WithAction", // Route name
"{controller}/{rssactionname}/{rssactionid}/rss", // URL with parameters
new { controller = "Posts", action = "Rss", rssactionname = "Index" }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
routes.JumblistMapRoute(
"Rss", // Route name
"{controller}/rss", // URL with parameters
new { controller = "Posts", action = "Rss", rssactionname = "Index" }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
routes.JumblistMapRoute(
"Category", // Route name
"{controller}/{action}/{id}/{category}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional, category = UrlParameter.Optional }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
routes.JumblistMapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "Jumblist.Website.Controllers" }
);
//routes.Add(
// new JumblistRoute(
// "{controller}/{action}/{id}",
// new RouteValueDictionary( new {
//.........这里部分代码省略.........