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 }); }
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 ); }
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; }
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 }); }
static void ConvertRoutesToLowercase(RouteCollection routes) { var lowercaseRoutes = routes.Select(r => new LowercaseRoute(r)).ToArray(); routes.Clear(); foreach (var route in lowercaseRoutes) { routes.Add(route); } }
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); }
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)); } } }
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(); }; }
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"} ); }
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} ); }
/// <summary> /// This fuction call from Global AppStart and App-BeginRequest /// On AppStart this function initialize default route and cms page route. /// On App=BeginRequest it chack if Cms Slug exist or not. If exist it do nothing else it clear /// all route and recreate new route /// </summary> /// <param name="routes"></param> /// <param name="initialCall"></param> public static void RegisterRoutes(RouteCollection routes, bool initialCall = true) { if (!initialCall) { var cackekey = string.Format(CacheKeys.SiteViewAllSlug, ConfigKeys.OmnicxDomainId); if (CacheManager.IsKeyExist(cackekey)) { return; } } routes.Clear(); var siteViewApi = DependencyResolver.Current.GetService <ISiteViewApi>(); var slugs = siteViewApi.GetSiteViewAllSlug(); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.LowercaseUrls = true; var slugCount = 1; if (slugs?.Result != null) { foreach (var slug in slugs.Result.Distinct()) //Added distict for removing duplicate slugs { routes.MapRoute(name: "slug" + slugCount.ToString(), url: slug, defaults: new { controller = "Page", action = "DynamicPage", slug = UrlParameter.Optional }); slugCount++; } } routes.MapRoute(name: "sitemap", url: "sitemap.xml", defaults: new { controller = "Page", action = "GetFeedLink", slug = "sitemap" }); routes.MapRoute(name: "brands-all", url: "brands", defaults: new { controller = "Brand", action = "BrandList", id = UrlParameter.Optional }); routes.MapRoute(name: "brand-detail", url: "brands/{name}", defaults: new { controller = "Brand", action = "BrandDetail", id = UrlParameter.Optional }); routes.MapRoute(name: "brand-productslist", url: "brands/{name}/all", defaults: new { controller = "Brand", action = "BrandProducts", id = UrlParameter.Optional }); routes.MapRoute(name: "brand-home", url: "brands/brand-home", defaults: new { controller = "Brand", action = "BrandLanding" }); routes.MapRoute(name: "myaccount", url: "myaccount", defaults: new { controller = "Account", action = "MyAccount" }); routes.MapRoute(name: "search", url: "search", defaults: new { controller = "Search", action = "Search", id = UrlParameter.Optional }); routes.MapRoute(name: "categories-products", url: "categories/categories-products", defaults: new { controller = "Category", action = "CategoryLanding2" }); routes.MapRoute(name: "categories", url: "categories", defaults: new { controller = "Category", action = "CategoryList" }); //routes.MapRoute(name: "errorblog", url: "blog/blogs", defaults: new { controller = "Common", action = "PageNotFound", url = UrlParameter.Optional }); routes.MapRoute(name: "catalogue", url: SiteRouteUrl.Category + "/{categorySlug}/{groupSlug}/{linkSlug}/{linkSlug1}", defaults: new { controller = "Category", action = "CategoryLanding", categorySlug = UrlParameter.Optional, groupSlug = UrlParameter.Optional, linkSlug = UrlParameter.Optional, linkSlug1 = UrlParameter.Optional }); routes.MapRoute(name: "product", url: "products/{name}", defaults: new { controller = "Product", action = "ProductDetail", name = UrlParameter.Optional }); routes.MapRoute(name: "bloglisting", url: "blogs", defaults: new { controller = "Blog", action = "Blogs", url = UrlParameter.Optional }); routes.MapRoute(name: "blogs", url: "blogs/{url}", defaults: new { controller = "Blog", action = "BlogDetail", url = UrlParameter.Optional }); routes.MapRoute(name: "blog-category", url: "blog-category/{slug}/{currentpage}", defaults: new { controller = "Blog", action = "GetAllBlogsbyCategory", slug = UrlParameter.Optional, currentpage = UrlParameter.Optional }); routes.MapRoute(name: "blog-type", url: "blog-type/{slug}/{currentpage}", defaults: new { controller = "Blog", action = "GetAllBlogsByType", slug = UrlParameter.Optional, currentpage = UrlParameter.Optional }); routes.MapRoute(name: "blog-editor", url: "blog-editor/{slug}/{currentpage}", defaults: new { controller = "Blog", action = "GetAllBlogsByEditor", slug = UrlParameter.Optional, currentpage = UrlParameter.Optional }); routes.MapRoute(name: "checkout", url: "std/{basketId}", defaults: new { controller = "Checkout", action = "StandardCheckout", basketId = UrlParameter.Optional }); routes.MapRoute(name: "onepagecheckout", url: "opc/{basketId}", defaults: new { controller = "Checkout", action = "OnePageCheckout", basketId = UrlParameter.Optional }); routes.MapRoute(name: "quotePayment", url: "quote/{link}", defaults: new { controller = "B2B", action = "ValidateQuotePayment", link = UrlParameter.Optional }); routes.MapRoute(name: "dynamic-list", url: "list/{slug}", defaults: new { controller = "Search", action = "DynamicListItems", slug = UrlParameter.Optional }); routes.MapRoute(name: "dynamic-page", url: "{slug}", defaults: new { controller = "Page", action = "DynamicPage", slug = UrlParameter.Optional }); routes.MapRoute(name: "passwordrecovery", url: "passwordrecovery/{id}", defaults: new { controller = "Account", action = "PasswordRecovery", id = UrlParameter.Optional }); routes.MapRoute(name: "feed", url: "feed/{slug}", defaults: new { controller = "Page", action = "GetFeedLink", slug = UrlParameter.Optional }); //Payment Method post notification route handlers routes.MapRoute(name: "MasterCardNotification", url: "checkout/mastercardnotification", defaults: new { controller = "MasterCard", action = "Notification", id = UrlParameter.Optional }); routes.MapRoute(name: "MasterCardCheck3DSecure", url: "checkout/MasterCardCheck3DSecure", defaults: new { controller = "MasterCard", action = "Check3DSecure", id = UrlParameter.Optional }); routes.MapRoute(name: "MasterCardAuthorize", url: "checkout/MasterCardAuthorize", defaults: new { controller = "MasterCard", action = "Authorize", id = UrlParameter.Optional }); routes.MapRoute(name: "Paypalnotification", url: "checkout/Paypalnotification", defaults: new { controller = "Paypal", action = "Notification", id = UrlParameter.Optional }); routes.MapRoute(name: "CODPaymentResponse", url: "checkout/PaymentResponse", defaults: new { controller = "COD", action = "PaymentResponse", id = UrlParameter.Optional }); routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Page", action = "DynamicPage", id = UrlParameter.Optional }); // routes.MapRoute(name: "Default1", url: "{*.*}", defaults: new { controller = "Page", action = "DynamicPage", id = UrlParameter.Optional }); }
/// <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"}); }
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 } ); routes.MapRoute( name: "Login", url: "login", defaults: new { controller = "Website", action = "Login" } ); routes.MapRoute( name: "Logout", url: "logout", defaults: new { controller = "Website", action = "Logout" } ); routes.MapRoute( name: "Registration", url: "registration", defaults: new { controller = "Website", action = "Registration" } ); routes.MapRoute( name: "PassReminder", url: "pass-reminder", defaults: new { controller = "Website", action = "ForgottenPassword" } ); routes.MapRoute( name: "Basket", url: "basket", defaults: new { controller = "Website", action = "Basket" } ); routes.MapRoute( name: "Checkout", url: "checkout", defaults: new { controller = "Website", action = "Checkout" } ); routes.MapRoute( name: "OrderSummary", url: "summaryandpayment", defaults: new { controller = "Website", action = "OrderSummary" } ); routes.MapRoute( name: "XMLSitemap", url: "sitemap.xml", defaults: new { controller = "Website", action = "XMLSitemap" } ); routes.MapRoute( name: "RegisterConfirmation", url: "register-confirmation", defaults: new { controller = "Website", action = "RegisterConfirmation" } ); routes.MapRoute( name: "RobotsTXT", url: "robots.txt", defaults: new { controller = "Website", action = "RobotsTXT" } ); var contentService = (IWebContent)DependencyResolver.Current.GetService(typeof(IWebContent)); var domainService = (IDomain)DependencyResolver.Current.GetService(typeof(IDomain)); List<tbl_Domains> domains = domainService.GetAllDomains(); #if DEBUG var localhostDomain = domainService.GetDomainByID(SettingsManager.LocalHostDomainID); if (localhostDomain == null) { localhostDomain = new tbl_Domains { DomainID = SettingsManager.LocalHostDomainID }; domains.Add(localhostDomain); } string processName = Process.GetCurrentProcess().ProcessName.ToLower(); bool isRunningInIisExpress = processName.Contains("iisexpress") || processName.Contains("webdev.webserver"); if (isRunningInIisExpress) localhostDomain.DO_Domain = "localhost"; #endif foreach (var domain in domains) { string newsPath = contentService.GetSitemapUrlByType(SiteMapType.News, domain.DomainID), testimonialsPath = contentService.GetSitemapUrlByType(SiteMapType.Testimonials, domain.DomainID), prodCategoriesPath = contentService.GetSitemapUrlByType(SiteMapType.ProductShop, domain.DomainID), eventCategoriesPath = contentService.GetSitemapUrlByType(SiteMapType.EventShop, domain.DomainID), sitemapPath = contentService.GetSitemapUrlByType(SiteMapType.Sitemap, domain.DomainID), subscribePath = contentService.GetSitemapUrlByType(SiteMapType.Subscribe, domain.DomainID), donationPath = contentService.GetSitemapUrlByType(SiteMapType.Donation, domain.DomainID), poiPath = contentService.GetSitemapUrlByType(SiteMapType.PointsOfInterest, domain.DomainID), portfolioPath = contentService.GetSitemapUrlByType(SiteMapType.Portfolio, domain.DomainID), galleryPath = contentService.GetSitemapUrlByType(SiteMapType.Gallery, domain.DomainID); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: donationPath.Trim('/'), defaults: new { controller = "Website", action = "DonationCategories" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: subscribePath.Trim('/'), defaults: new { controller = "Website", action = "Subscribe", email = UrlParameter.Optional } )); if (!domain.DO_CustomRouteHandler) { routes.Add(new DomainRoute( domain: domain.DO_Domain, url: eventCategoriesPath.Trim('/'), defaults: new {controller = "Website", action = "EventsCategories"} )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: prodCategoriesPath.Trim('/'), defaults: new {controller = "Website", action = "ProdCategories"} )); } routes.Add(new DomainRoute( domain: domain.DO_Domain, url: portfolioPath.Trim('/'), defaults: new { controller = "Website", action = "Portfolio" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", portfolioPath.Trim('/'), "{*query}"), defaults: new { controller = "Website", action = "PortfolioItem" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: galleryPath.Trim('/'), defaults: new { controller = "Website", action = "Gallery" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", galleryPath.Trim('/'), "{*query}"), defaults: new { controller = "Website", action = "GalleryItem" } )); if (!domain.DO_CustomRouteHandler) { routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", eventCategoriesPath.Trim('/'), "{*query}"), defaults: new {controller = "Website", action = "Events"} )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", prodCategoriesPath.Trim('/'), "{*query}"), defaults: new {controller = "Website", action = "Products"} )); } routes.Add(new DomainRoute( domain: domain.DO_Domain, url: testimonialsPath.Trim('/'), defaults: new { controller = "Website", action = "Testimonials" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: sitemapPath.Trim('/'), defaults: new { controller = "Website", action = "Sitemap" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}", newsPath.Trim('/'), SettingsManager.Blog.SearchUrl.Trim('/'), "{keyword}"), defaults: new { controller = "Website", action = "BlogSearch", keyword = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", newsPath.Trim('/'), "feed"), defaults: new { controller = "Website", action = "GetBlogRss" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: newsPath.Trim('/'), defaults: new { controller = "Website", action = "Blog" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}", newsPath.Trim('/'), SettingsManager.Blog.CategoryUrl.Trim('/'), "{name}"), defaults: new { controller = "Website", action = "BlogCategory", name = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}", newsPath.Trim('/'), SettingsManager.Blog.TagUrl.Trim('/'), "{name}"), defaults: new { controller = "Website", action = "BlogTag", name = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}/{3}", newsPath.Trim('/'), "{year}", "{month}", "{title}"), defaults: new { controller = "Website", action = "Blog", year = UrlParameter.Optional, month = UrlParameter.Optional, title = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: poiPath.Trim('/'), defaults: new { controller = "Website", action = "POIs" } )); } Route customRoute = new Route("{*values}", new CMS.UI.Common.CustomRouteHandler()); routes.Add("customRouter", customRoute); //routes.MapRoute( // name: "Default", // url: "{*values}", // defaults: new { controller = "Website", action = "Content" } //); //routes.MapRoute( // name: "Default", // url: "{controller}/{action}/{id}", // defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } //); }
/// <summary> /// 发布路由。 /// </summary> /// <param name="routes">路由集合。</param> public void Publish(IEnumerable <RouteDescriptor> routes) { //排序。 var routesArray = routes .OrderByDescending(r => r.Priority) .ToArray(); //发布前事件。 _routePublisherEventHandlers.Invoke(i => i.Publishing(routesArray), NullLogger.Instance); using (_routeCollection.GetWriteLock()) { //释放现有路由。 _routeCollection .OfType <HubRoute>().Invoke(x => x.ReleaseShell(_shellSettings), NullLogger.Instance); var routeList = new List <RouteBase>(_routeCollection); //添加新路由 foreach (var routeDescriptor in routesArray) { //根据Route得到扩展描述符 ExtensionDescriptorEntry extensionDescriptor = null; if (routeDescriptor.Route is Route) { object extensionId; var route = routeDescriptor.Route as Route; if (route.DataTokens != null && route.DataTokens.TryGetValue("area", out extensionId) || route.Defaults != null && route.Defaults.TryGetValue("area", out extensionId)) { extensionDescriptor = _extensionManager.GetExtension(extensionId.ToString()); } } else if (routeDescriptor.Route is IRouteWithArea) { var route = routeDescriptor.Route as IRouteWithArea; extensionDescriptor = _extensionManager.GetExtension(route.Area); } //加载会话状态信息。 var sessionState = SessionStateBehavior.Default; if (extensionDescriptor != null) { if (routeDescriptor.SessionState == SessionStateBehavior.Default) { var descriptor = extensionDescriptor.Descriptor; if (descriptor.Keys.Contains("SessionState")) { Enum.TryParse(descriptor["SessionState"], true, out sessionState); } } } //设置SessionState var sessionStateBehavior = routeDescriptor.SessionState == SessionStateBehavior.Default ? sessionState : routeDescriptor.SessionState; //创建外壳路由 var shellRoute = new ShellRoute(routeDescriptor.Route, _shellSettings, _webWorkContextAccessor, _runningShellTable) { IsHttpRoute = routeDescriptor is HttpRouteDescriptor, SessionState = sessionStateBehavior }; //区域 var area = extensionDescriptor == null ? string.Empty : extensionDescriptor.Id; //尝试查找已存在的集线器路由 var matchedHubRoute = routeList.FirstOrDefault(x => { var hubRoute = x as HubRoute; if (hubRoute == null) { return(false); } return(routeDescriptor.Priority == hubRoute.Priority && hubRoute.Area.Equals(area, StringComparison.OrdinalIgnoreCase) && hubRoute.Name == routeDescriptor.Name); }) as HubRoute; //创建新的集线器路由。 if (matchedHubRoute == null) { matchedHubRoute = new HubRoute(routeDescriptor.Name, area, routeDescriptor.Priority, _runningShellTable); int index; for (index = 0; index < routeList.Count; index++) { var hubRoute = routeList[index] as HubRoute; if (hubRoute == null) { continue; } if (hubRoute.Priority < matchedHubRoute.Priority) { break; } } routeList.Insert(index, matchedHubRoute); } matchedHubRoute.Add(shellRoute, _shellSettings); } //清空现有路由。 _routeCollection.Clear(); foreach (var item in routeList) { if (item is HubRoute) { _routeCollection.Add((item as HubRoute).Name, item); } else { _routeCollection.Add(item); } } } //发布后事件。 _routePublisherEventHandlers.Invoke(i => i.Published(routesArray), NullLogger.Instance); }
/// <summary> /// Registers the routes. /// </summary> /// <param name="routes">The routes.</param> private void RegisterRoutes( RockContext rockContext, RouteCollection routes ) { routes.Clear(); PageRouteService pageRouteService = new PageRouteService( rockContext ); // Add ingore rule for asp.net ScriptManager files. routes.Ignore("{resource}.axd/{*pathInfo}"); // Add page routes foreach ( var route in pageRouteService .Queryable().AsNoTracking() .GroupBy( r => r.Route ) .Select( s => new { Name = s.Key, Pages = s.Select( pr => new Rock.Web.PageAndRouteId { PageId = pr.PageId, RouteId = pr.Id } ).ToList() } ) .ToList() ) { routes.AddPageRoute( route.Name, route.Pages ); } // Add a default page route routes.Add( new Route( "page/{PageId}", new Rock.Web.RockRouteHandler() ) ); // Add a default route for when no parameters are passed routes.Add( new Route( "", new Rock.Web.RockRouteHandler() ) ); }
/// <summary> /// Registers the routes. /// </summary> /// <param name="routes">The routes.</param> private void RegisterRoutes( RockContext rockContext, RouteCollection routes ) { routes.Clear(); PageRouteService pageRouteService = new PageRouteService( rockContext ); // find each page that has defined a custom routes. foreach ( PageRoute pageRoute in pageRouteService.Queryable() ) { // Create the custom route and save the page id in the DataTokens collection routes.AddPageRoute( pageRoute ); } // Add API route for dataviews routes.MapHttpRoute( name: "DataViewApi", routeTemplate: "api/{controller}/DataView/{id}", defaults: new { action = "DataView" } ); // Add any custom api routes foreach ( var type in Rock.Reflection.FindTypes( typeof( Rock.Rest.IHasCustomRoutes ) ) ) { var controller = (Rock.Rest.IHasCustomRoutes)Activator.CreateInstance( type.Value ); if ( controller != null ) controller.AddRoutes( routes ); } // Add Default API Service routes // Instead of being able to use one default route that gets action from http method, have to // have a default route for each method so that other actions do not match the default (i.e. DataViews) routes.MapHttpRoute( name: "DefaultApiGet", routeTemplate: "api/{controller}/{id}", defaults: new { action = "GET", id = System.Web.Http.RouteParameter.Optional }, constraints: new { httpMethod = new HttpMethodConstraint( new string[] { "GET" } ) } ); routes.MapHttpRoute( name: "DefaultApiPut", routeTemplate: "api/{controller}/{id}", defaults: new { action = "PUT", id = System.Web.Http.RouteParameter.Optional }, constraints: new { httpMethod = new HttpMethodConstraint( new string[] { "PUT" } ) } ); routes.MapHttpRoute( name: "DefaultApiPost", routeTemplate: "api/{controller}/{id}", defaults: new { action = "POST", id = System.Web.Http.RouteParameter.Optional }, constraints: new { httpMethod = new HttpMethodConstraint( new string[] { "POST" } ) } ); routes.MapHttpRoute( name: "DefaultApiDelete", routeTemplate: "api/{controller}/{id}", defaults: new { action = "DELETE", id = System.Web.Http.RouteParameter.Optional }, constraints: new { httpMethod = new HttpMethodConstraint( new string[] { "DELETE" } ) } ); // Add a default page route routes.Add( new Route( "page/{PageId}", new Rock.Web.RockRouteHandler() ) ); // Add a default route for when no parameters are passed routes.Add( new Route( "", new Rock.Web.RockRouteHandler() ) ); }
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( "ProfileInfo", "{uid}/Info", new { controller = "Profile", action = "Info" } ); routes.MapRouteLowercase( "Profile", "{uid}", new { controller = "Feed", action = "Feeds" } ); routes.MapRouteLowercase( "ProfileAction", "{uid}/{action}", new { controller = "Profile" } ); }
public void NameIsOptional() { routes.Clear(); routes.MapRoute(null, ""); }
[Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=13909 public void MapPageRoute_Bug13909 () { var c = new RouteCollection (); c.MapPageRoute("test", "test", "~/test.aspx"); c.Clear(); c.MapPageRoute("test", "test", "~/test.aspx"); }
public static void RegisterRoutes(RouteCollection routes) { routes.Clear(); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); }
public static void RegisterRoutes(RouteCollection routes) { routes.Clear(); routes.RouteExistingFiles = true; routes.IgnoreRoute("{resource}.asp/{*pathInfo}"); routes.IgnoreRoute("{resource}.txt/{*pathInfo}"); routes.IgnoreRoute("{resource}.html/{*pathInfo}"); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("Content/{*pathInfo}"); routes.IgnoreRoute("movies/{*pathInfo}"); routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" }); routes.MapRoute( name: "Home", url: "", defaults: new { controller = "Home", action = "Index" } ); routes.MapRoute( name: "Links", url: "Links", defaults: new { controller = "Links", action = "Index" } ); routes.MapRoute( name: "Nieuws", url: "Nieuws", defaults: new { controller = "News", action = "Index" } ); routes.MapRoute( name: "Cookies", url: "Cookies", defaults: new { controller = "Cookie", action = "Index" } ); routes.MapRoute( name: "Contact", url: "Contact", defaults: new { controller = "Contact", action = "Index" } ); routes.MapRoute( name: "Bedankt", url: "Bedankt", defaults: new { controller = "Contact", action = "Thanks" } ); routes.MapRoute( name: "Wiki", url: "Wiki", defaults: new { controller = "Wiki", action = "Index" } ); routes.MapRoute( name: "Zoeken", url: "Zoeken", defaults: new { controller = "Search", action = "Index" } ); routes.MapRoute( name: "Spelers", url: "Spelers", defaults: new { controller = "Player", action = "Index" } ); routes.MapRoute( name: "SpelersOverzicht", url: "Spelers/Overzicht/{c}/{page}", defaults: new { controller = "Player", action = "Overview", page = UrlParameter.Optional } ); routes.MapRoute( name: "SpelersDetails", url: "Spelers/{id}/{name}", defaults: new { controller = "Player", action = "Details", name = UrlParameter.Optional } ); routes.MapRoute( name: "Verenigingen", url: "Verenigingen", defaults: new { controller = "Club", action = "Index" } ); routes.MapRoute( name: "VerenigingenOverzicht", url: "Verenigingen/Overzicht/{c}", defaults: new { controller = "Club", action = "Overview" } ); routes.MapRoute( name: "VerenigingenDetails", url: "Verenigingen/{id}/{name}", defaults: new { controller = "Club", action = "Details", name = UrlParameter.Optional } ); routes.MapRoute( name: "VerenigingenSpelers", url: "Verenigingen/{id}/{clubName}/Resultaten/{season}/{seasonName}", defaults: new { controller = "Club", action = "Players" } ); routes.MapRoute( name: "VerenigingenTeams", url: "Verenigingen/{id}/{clubName}/Teams/{season}/{seasonName}", defaults: new { controller = "Club", action = "Teams" } ); routes.MapRoute( name: "VerenigingenHistorie", url: "Verenigingen/{id}/{clubName}/Historie", defaults: new { controller = "Club", action = "PlayerHistory" } ); routes.MapRoute( name: "TeamDetails", url: "Team/{id}/{name}", defaults: new { controller = "Team", action = "Details", name = UrlParameter.Optional } ); routes.MapRoute( name: "PouleDetails", url: "Poule/{id}/{name}", defaults: new { controller = "Poule", action = "Details", name = UrlParameter.Optional } ); routes.MapRoute( name: "Competities", url: "Competities", defaults: new { controller = "Poule", action = "Index" } ); routes.MapRoute( name: "CompetitiesOverzicht", url: "Competities/{season}/{category}/{region}/{seasonName}/{categoryName}/{regionName}", defaults: new { controller = "Poule", action = "Index" } ); routes.MapRoute( name: "StatistiekenSpelers", url: "Statistieken/Spelers", defaults: new { controller = "Statistics", action = "Players" } ); routes.MapRoute( name: "StatistiekenSpelersJunioren", url: "Statistieken/Spelers/Junioren", defaults: new { controller = "Statistics", action = "PlayersYouth" } ); routes.MapRoute( name: "StatistiekenSpelersSenioren", url: "Statistieken/Spelers/Senioren", defaults: new { controller = "Statistics", action = "PlayersAdult" } ); routes.MapRoute( name: "StatistiekenVerenigingen", url: "Statistieken/Verenigingen", defaults: new { controller = "Statistics", action = "Clubs" } ); routes.MapRoute( name: "RatingsUitleg", url: "Ratings/Uitleg", defaults: new { controller = "Rating", action = "Explanation" } ); routes.MapRoute( name: "RatingsPerRegioStart", url: "Ratings/Afdeling", defaults: new { controller = "Rating", action = "Region" } ); routes.MapRoute( name: "RatingsPerRegio", url: "Ratings/Afdeling/{region}/{regionName}/{category}", defaults: new { controller = "Rating", action = "Region", region = UrlParameter.Optional, regionName = UrlParameter.Optional, category = UrlParameter.Optional } ); routes.MapRoute( name: "RatingsPerSeizoenStart", url: "Ratings/Seizoen", defaults: new { controller = "Rating", action = "Season" } ); routes.MapRoute( name: "RatingsPerSeizoen", url: "Ratings/Seizoen/{season}/{seasonName}/{category}", defaults: new { controller = "Rating", action = "Season", season = UrlParameter.Optional, seasonName = UrlParameter.Optional, category = UrlParameter.Optional } ); routes.MapRoute( name: "GegevensNietGevonden", url: "Error", defaults: new { controller = "Error", action = "Index" } ); routes.MapRoute( name: "Keepalive", url: "Keepalive", defaults: new { controller = "Keepalive", action = "Index" } ); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
public void Dispose() { testRoutes.Clear(); }
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 } ); routes.MapRoute( name: "Login", url: "login", defaults: new { controller = "Website", action = "Login" } ); routes.MapRoute( name: "Logout", url: "logout", defaults: new { controller = "Website", action = "Logout" } ); routes.MapRoute( name: "Registration", url: "registration", defaults: new { controller = "Website", action = "Registration" } ); routes.MapRoute( name: "PassReminder", url: "pass-reminder", defaults: new { controller = "Website", action = "ForgottenPassword" } ); routes.MapRoute( name: "Basket", url: "basket", defaults: new { controller = "Website", action = "Basket" } ); routes.MapRoute( name: "Checkout", url: "checkout", defaults: new { controller = "Website", action = "Checkout" } ); routes.MapRoute( name: "OrderSummary", url: "summaryandpayment", defaults: new { controller = "Website", action = "OrderSummary" } ); routes.MapRoute( name: "XMLSitemap", url: "sitemap.xml", defaults: new { controller = "Website", action = "XMLSitemap" } ); routes.MapRoute( name: "RegisterConfirmation", url: "register-confirmation", defaults: new { controller = "Website", action = "RegisterConfirmation" } ); routes.MapRoute( name: "RobotsTXT", url: "robots.txt", defaults: new { controller = "Website", action = "RobotsTXT" } ); var contentService = (IWebContent)DependencyResolver.Current.GetService(typeof(IWebContent)); var domainService = (IDomain)DependencyResolver.Current.GetService(typeof(IDomain)); List <tbl_Domains> domains = domainService.GetAllDomains(); #if DEBUG var localhostDomain = domainService.GetDomainByID(SettingsManager.LocalHostDomainID); if (localhostDomain == null) { localhostDomain = new tbl_Domains { DomainID = SettingsManager.LocalHostDomainID }; domains.Add(localhostDomain); } string processName = Process.GetCurrentProcess().ProcessName.ToLower(); bool isRunningInIisExpress = processName.Contains("iisexpress") || processName.Contains("webdev.webserver"); if (isRunningInIisExpress) { localhostDomain.DO_Domain = "localhost"; } #endif foreach (var domain in domains) { string newsPath = contentService.GetSitemapUrlByType(SiteMapType.News, domain.DomainID), testimonialsPath = contentService.GetSitemapUrlByType(SiteMapType.Testimonials, domain.DomainID), prodCategoriesPath = contentService.GetSitemapUrlByType(SiteMapType.ProductShop, domain.DomainID), eventCategoriesPath = contentService.GetSitemapUrlByType(SiteMapType.EventShop, domain.DomainID), sitemapPath = contentService.GetSitemapUrlByType(SiteMapType.Sitemap, domain.DomainID), subscribePath = contentService.GetSitemapUrlByType(SiteMapType.Subscribe, domain.DomainID), donationPath = contentService.GetSitemapUrlByType(SiteMapType.Donation, domain.DomainID), poiPath = contentService.GetSitemapUrlByType(SiteMapType.PointsOfInterest, domain.DomainID), portfolioPath = contentService.GetSitemapUrlByType(SiteMapType.Portfolio, domain.DomainID), galleryPath = contentService.GetSitemapUrlByType(SiteMapType.Gallery, domain.DomainID); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: donationPath.Trim('/'), defaults: new { controller = "Website", action = "DonationCategories" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: subscribePath.Trim('/'), defaults: new { controller = "Website", action = "Subscribe", email = UrlParameter.Optional } )); if (!domain.DO_CustomRouteHandler) { routes.Add(new DomainRoute( domain: domain.DO_Domain, url: eventCategoriesPath.Trim('/'), defaults: new { controller = "Website", action = "EventsCategories" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: prodCategoriesPath.Trim('/'), defaults: new { controller = "Website", action = "ProdCategories" } )); } routes.Add(new DomainRoute( domain: domain.DO_Domain, url: portfolioPath.Trim('/'), defaults: new { controller = "Website", action = "Portfolio" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", portfolioPath.Trim('/'), "{*query}"), defaults: new { controller = "Website", action = "PortfolioItem" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: galleryPath.Trim('/'), defaults: new { controller = "Website", action = "Gallery" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", galleryPath.Trim('/'), "{*query}"), defaults: new { controller = "Website", action = "GalleryItem" } )); if (!domain.DO_CustomRouteHandler) { routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", eventCategoriesPath.Trim('/'), "{*query}"), defaults: new { controller = "Website", action = "Events" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", prodCategoriesPath.Trim('/'), "{*query}"), defaults: new { controller = "Website", action = "Products" } )); } routes.Add(new DomainRoute( domain: domain.DO_Domain, url: testimonialsPath.Trim('/'), defaults: new { controller = "Website", action = "Testimonials" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: sitemapPath.Trim('/'), defaults: new { controller = "Website", action = "Sitemap" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}", newsPath.Trim('/'), SettingsManager.Blog.SearchUrl.Trim('/'), "{keyword}"), defaults: new { controller = "Website", action = "BlogSearch", keyword = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}", newsPath.Trim('/'), "feed"), defaults: new { controller = "Website", action = "GetBlogRss" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: newsPath.Trim('/'), defaults: new { controller = "Website", action = "Blog" } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}", newsPath.Trim('/'), SettingsManager.Blog.CategoryUrl.Trim('/'), "{name}"), defaults: new { controller = "Website", action = "BlogCategory", name = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}", newsPath.Trim('/'), SettingsManager.Blog.TagUrl.Trim('/'), "{name}"), defaults: new { controller = "Website", action = "BlogTag", name = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: String.Format("{0}/{1}/{2}/{3}", newsPath.Trim('/'), "{year}", "{month}", "{title}"), defaults: new { controller = "Website", action = "Blog", year = UrlParameter.Optional, month = UrlParameter.Optional, title = UrlParameter.Optional } )); routes.Add(new DomainRoute( domain: domain.DO_Domain, url: poiPath.Trim('/'), defaults: new { controller = "Website", action = "POIs" } )); } Route customRoute = new Route("{*values}", new CMS.UI.Common.CustomRouteHandler()); routes.Add("customRouter", customRoute); //routes.MapRoute( // name: "Default", // url: "{*values}", // defaults: new { controller = "Website", action = "Content" } //); //routes.MapRoute( // name: "Default", // url: "{controller}/{action}/{id}", // defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } //); }
private void RefreshApplicationData() { // TODO (Roman): try/catch errorhandling? IApplicationContext context = InstanceContainer.ApplicationContext; #region context data context.Refresh(context.BaseDirectory); #endregion #region database content // TODO (Roman): this must be done at the windows service, not at a web client app Dictionary <string, List <IWikiLanguageThreadLookupItem> > wikiLanguageThreadIdLookup = new Dictionary <string, List <IWikiLanguageThreadLookupItem> >(); Dictionary <string, IWikiLanguageThreadLookupItem> wikiLanguageThreadIds = new Dictionary <string, IWikiLanguageThreadLookupItem>(); IApplicationManager applicationManger = InstanceContainer.ApplicationManager; IArticleGroupManager articleGroupManager = InstanceContainer.ArticleGroupManager; IArticleGroupThreadManager articleGroupThreadManager = InstanceContainer.ArticleGroupThreadManager; ISystemProfileImageManager systemProfileImageManager = InstanceContainer.SystemProfileImageManager; IApplication application; IStaticContentLookup staticContentLookup; ArticleGroupThread articleGroupThread; ArticleGroup articleGroup; IApplicationThemeInfo[] applicationThemeInfos = context.GetAllApplicationThemeInfos(); Dictionary <int, IApplication> applicationLookup = new Dictionary <int, IApplication>(); #region applications foreach (IApplicationThemeInfo applicationThemeInfo in applicationThemeInfos) { application = applicationManger.GetApplication(applicationThemeInfo.ApplicationName); if (application == null) { application = new Workmate.Components.Entities.Application(applicationThemeInfo.ApplicationName, "Generated on Application Data Refresh at " + DateTime.UtcNow.ToString() + " (UTC)"); #region do default settings - we really want this to be prepopulated by sql scripts application.DefaultAdminSenderEmailAddress = "admin@" + applicationThemeInfo.ApplicationName + ".com"; #endregion var report = applicationManger.Create(application); if (report.Status != DataRepositoryActionStatus.Success) { // TODO (Roman): error handling? continue; } } // this was not set yet as the context refresh above did not have all data available, so we have to do it here applicationThemeInfo.ApplicationId = application.ApplicationId; applicationThemeInfo.Application = application; applicationLookup[application.ApplicationId] = application; } #endregion #region Userroles string[] userRoles = Enum.GetNames(typeof(UserRole)); foreach (int applicationId in applicationLookup.Keys) { InstanceContainer.WorkmateRoleProvider.CreateRolesIfNotExist(applicationId, userRoles); } #endregion IThemeFolderLookup themeFolderLookup; Dictionary <string, SystemProfileImage> systemProfileImageLookup; HashSet <int> usedApplicationIds = new HashSet <int>(); foreach (IApplicationThemeInfo applicationThemeInfo in applicationThemeInfos.Where(c => c.ApplicationGroup == MagicStrings.APPLICATIONGROUP_NAME_WORKMATE)) { themeFolderLookup = context.GetThemeFolderLookup(applicationThemeInfo.ApplicationGroup); #region profile images if (!usedApplicationIds.Contains(applicationThemeInfo.ApplicationId)) { systemProfileImageLookup = systemProfileImageManager.GetSystemProfileImages(applicationThemeInfo.ApplicationId); if (!systemProfileImageLookup.ContainsKey(MagicStrings.PROFILE_IMAGE_MALE_FILENAME)) { if (File.Exists(applicationThemeInfo.Images.DefaultThemeImageFolderServerPath + MagicStrings.PROFILE_IMAGE_MALE_FILENAME)) { TryCreateSystemProfileImage(themeFolderLookup, applicationThemeInfo , applicationThemeInfo.Images.DefaultThemeImageFolderServerPath + MagicStrings.PROFILE_IMAGE_MALE_FILENAME , MagicStrings.PROFILE_IMAGE_MALE_FILENAME); } } if (!systemProfileImageLookup.ContainsKey(MagicStrings.PROFILE_IMAGE_FEMALE_FILENAME)) { if (File.Exists(applicationThemeInfo.Images.DefaultThemeImageFolderServerPath + MagicStrings.PROFILE_IMAGE_FEMALE_FILENAME)) { TryCreateSystemProfileImage(themeFolderLookup, applicationThemeInfo , applicationThemeInfo.Images.DefaultThemeImageFolderServerPath + MagicStrings.PROFILE_IMAGE_FEMALE_FILENAME , MagicStrings.PROFILE_IMAGE_FEMALE_FILENAME); } } // now reload in case we've created profile images for the first time systemProfileImageLookup = systemProfileImageManager.GetSystemProfileImages(applicationThemeInfo.ApplicationId); foreach (SystemProfileImage systemProfileImage in systemProfileImageLookup.Values) { TrySaveProfileImage(systemProfileImage, applicationThemeInfo, MagicStrings.FOLDER_IMAGES_PROFILE_NORMAL, MagicNumbers.PROFILEIMAGE_SIZE_NORMAL); TrySaveProfileImage(systemProfileImage, applicationThemeInfo, MagicStrings.FOLDER_IMAGES_PROFILE_TINY, MagicNumbers.PROFILEIMAGE_SIZE_TINY); } usedApplicationIds.Add(applicationThemeInfo.ApplicationId); } systemProfileImageLookup = systemProfileImageManager.GetSystemProfileImages(applicationThemeInfo.ApplicationId); foreach (SystemProfileImage systemProfileImage in systemProfileImageLookup.Values) { switch (systemProfileImage.FriendlyFileName) { case MagicStrings.PROFILE_IMAGE_MALE_FILENAME: applicationThemeInfo.Images.MaleSystemProfileImageId = systemProfileImage.ImageId; break; case MagicStrings.PROFILE_IMAGE_FEMALE_FILENAME: applicationThemeInfo.Images.FemaleSystemProfileImageId = systemProfileImage.ImageId; break; } } #endregion #region create wiki language threads articleGroup = articleGroupManager.GetArticleGroup(applicationThemeInfo.ApplicationId, MagicStrings.WIKI_LANGUAGE_SECTION); if (articleGroup == null) { articleGroup = new ArticleGroup(applicationThemeInfo.ApplicationId, MagicStrings.WIKI_LANGUAGE_SECTION, true); articleGroup.Description = "Generated on Application Data Refresh at " + DateTime.UtcNow.ToString() + " (UTC)"; var report = articleGroupManager.Create(articleGroup); if (report.Status != DataRepositoryActionStatus.Success) { // TODO (Roman): error handling? continue; } } wikiLanguageThreadIds = new Dictionary <string, IWikiLanguageThreadLookupItem>(); staticContentLookup = context.GetStaticContentLookup(applicationThemeInfo.ApplicationGroup); foreach (string theme in themeFolderLookup.ThemeNames) { foreach (Language language in staticContentLookup.GetLanguages(theme)) { if (wikiLanguageThreadIds.ContainsKey(language.ShortCode)) { continue; } articleGroupThread = articleGroupThreadManager.GetArticleGroupThread(language.ShortCode); if (articleGroupThread == null) { articleGroupThread = new ArticleGroupThread(articleGroup, ArticleGroupThreadStatus.Enabled, language.ShortCode); articleGroupThread.IsApproved = true; articleGroupThread.IsLocked = false; var report = articleGroupThreadManager.Create(articleGroupThread); if (report.Status != DataRepositoryActionStatus.Success) { // TODO (Roman): error handling? continue; } } wikiLanguageThreadIds[language.ShortCode] = new WikiLanguageThreadLookupItem(language.ShortCode, language.Name, articleGroupThread.ArticleGroupThreadId); } } wikiLanguageThreadIdLookup[applicationThemeInfo.ApplicationName.ToLowerInvariant()] = wikiLanguageThreadIds.Values .ToList(); #endregion } IApplicationDataCache applicationDataCache = InstanceContainer.ApplicationDataCache; applicationDataCache.Refresh(wikiLanguageThreadIdLookup); #endregion #region routes RouteCollection routes = RouteTable.Routes; // TODO (Roman): get read lock as well? using (IDisposable writeLock = routes.GetWriteLock()) { routes.Clear(); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); ISitemapLookup sitemapLookup; Menu topMenu; MenuInfo menuInfo; Dictionary <string, Breadcrumb> breadCrumbs = new Dictionary <string, Breadcrumb>(); foreach (string applicationGroup in context.GetApplicationGroups()) { sitemapLookup = context.GetSitemapLookup(applicationGroup); breadCrumbs.Clear(); CreateBreadcrumbs(breadCrumbs, sitemapLookup); foreach (RouteTag routeTag in sitemapLookup.RouteTags) { topMenu = sitemapLookup.GetMenu(routeTag.TopMenuName); #region data tokens extensions routeTag.DataTokens[MagicStrings.DATATOKENS_BREADCRUMB] = breadCrumbs[routeTag.Name]; routeTag.DataTokens[MagicStrings.DATATOKENS_ROUTENAME] = routeTag.Name; menuInfo = new MenuInfo(); menuInfo.TopMenuName = routeTag.TopMenuName; if (topMenu != null) { foreach (MenuItem item in topMenu.MenuItems) { if (item.RouteName == routeTag.Name) { menuInfo.TopMenuItemName = item.Name; } foreach (MenuItem subItem in item.Children) { if (subItem.RouteName == routeTag.Name) { menuInfo.TopMenuItemName = subItem.Parent.Name; menuInfo.TopMenuSubItemName = subItem.Name; break; } } foreach (MenuItem subItem in item.DropdownMenuItems) { foreach (MenuItem dropdownSubItem in subItem.Children) { if (dropdownSubItem.RouteName == routeTag.Name) { menuInfo.TopMenuItemName = dropdownSubItem.Parent.Name; menuInfo.TopMenuSubItemName = dropdownSubItem.Name; break; } } } } } routeTag.DataTokens[MagicStrings.DATATOKENS_MENUINFO] = menuInfo; #endregion routes.Add( MagicStrings.FormatRouteName(applicationGroup, routeTag.Name) , new Route(routeTag.Url , routeTag.Defaults , routeTag.Constraints , routeTag.DataTokens , routeTag.RouteHandler)); } } } #endregion }
public static void RegisterRoutes(RouteCollection routes) { var section = ConfigurationManager.GetSection("RouteConfigSection") as RouteConfigSection; if (section == null || section.Routings.Count == 0) { return; } foreach (RouteConfigElement route in section.Routings) { if (route.Type == "clear") { routes.Clear(); } else if (route.Type == "ignore") { //ignore里的Constraints必须有值,或为null,跟map不一样 if (route.Constraints.Value.Count == 0) { routes.IgnoreRoute(route.Url); } else { routes.IgnoreRoute(route.Url, route.Constraints.Value); } } else if (route.Type == "map") { routes.Add(route.Name, new Route ( route.Url, route.Defaults.Value, route.Constraints.Value, route.DataTokens.Value, GetInstanceOfRouteHandler(route) ) ); } } }
public void IsNamedIndex() { var controller = typeof(DefaultAction.DefaultAction2Controller); routes.Clear(); routes.MapCodeRoutes(controller, new CodeRoutingSettings { RootOnly = true }); var httpContextMock = new Mock <HttpContextBase>(); httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/"); Assert.AreEqual("Index", routes.GetRouteData(httpContextMock.Object).GetRequiredString("action")); Assert.AreEqual("/", Url.Action("Index", controller)); controller = typeof(DefaultAction.DefaultAction5Controller); routes.Clear(); routes.MapCodeRoutes(controller, new CodeRoutingSettings { RootOnly = true }); httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/"); Assert.IsNull(routes.GetRouteData(httpContextMock.Object)); Assert.IsNull(Url.Action("", controller)); }
public static void RegisterRoutes(RouteCollection routes) { //routes.RouteExistingFiles = true; routes.Clear(); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); routes.Add("scm", new DomainRoute( "scm.dbzr.com", "{controller}/{action}/{id}", new { area = "", controller = "Account", action = "Login", id = UrlParameter.Optional } )); routes.Add("store", new DomainRoute( "store.dbzr.com", "{id}", new { area = "", controller = "Store", action = "Login", id = UrlParameter.Optional } )); routes.Add( "DomainRoute", new DomainRoute( "{dom}.{d1}.{d0}", "{controller}/{action}/{id}", new { controller = "Account", action = "Login", id = UrlParameter.Optional } )); routes.Add( "StoreRoute", new DomainRoute( "store{cid}-{sid}.{d1}.{d0}", "{controller}/{action}/{id}", new { controller = "Store", action = "Login", id = UrlParameter.Optional } )); //routes.MapRoute( // name: "StoreIpRoute", // url: "store{cid}-{sid}/{controller}/{action}/{id}/", // defaults: new { controller = "Store", action = "Login", id = UrlParameter.Optional } //); routes.Add( "StoreLocalhostRoute", new DomainRoute( "{localhost}", "store{cid}-{sid}/{controller}/{action}/{id}", new { controller = "Store", action = "Login", id = UrlParameter.Optional } )); routes.Add( "StoreIpRoute", new DomainRoute( "{ip1}.{ip2}.{ip3}.{ip4}", "store{cid}-{sid}/{controller}/{action}/{id}", new { controller = "Store", action = "Login", id = UrlParameter.Optional } )); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}/{*catchall}", defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional } ); }
public void Reset() { _routes.Clear(); }
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 { // controller = "Home", // action = "Index", // id = UrlParameter.Optional // } ), // new MvcRouteHandler() // ) //); }
public override void Clear() { _routeCollection.Clear(); }
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; } } }
public static void RegisterRoutes(RouteCollection routes) { routes.Clear(); routes.MapRoutes<Routes>(); }
/// <summary> /// This fuction call from Global AppStart and App-BeginRequest /// On AppStart this function initialize default route and cms page route. /// On App=BeginRequest it chack if Cms Slug exist or not. If exist it do nothing else it clear /// all route and recreate new route /// </summary> /// <param name="routes"></param> /// <param name="initialCall"></param> public static void RegisterRoutes(RouteCollection routes, bool initialCall = true) { //if (!initialCall) //{ // var cackekey = string.Format(CacheKeys.SiteViewAllSlug, ConfigKeys.OmnicxDomainId); // if (CacheManager.IsKeyExist(cackekey)) // return; //} routes.Clear(); //var siteViewApi = DependencyResolver.Current.GetService<ISiteViewApi>(); //var slugs = siteViewApi.GetSiteViewAllSlug(); //routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.LowercaseUrls = true; //var slugCount = 1; //if (slugs?.Result != null) //{ // foreach (var slug in slugs.Result.Distinct()) //Added distict for removing duplicate slugs // { // routes.MapRoute(name: "slug" + slugCount.ToString(), url: slug, defaults: new { controller = "Page", action = "DynamicPage", slug = UrlParameter.Optional }); // slugCount++; // } //} routes.MapRoute(name: "sitemap", url: "{slug}.xml", defaults: new { controller = "Page", action = "GetFeedLink", slug = UrlParameter.Optional }); routes.MapRoute(name: "feed", url: "feed{s}/{slug}", defaults: new { controller = "Page", action = "GetFeedLink", slug = UrlParameter.Optional, s = UrlParameter.Optional }); routes.MapRoute(name: "robots", url: "robots.txt", defaults: new { controller = "Page", action = "GetFeedLink", slug = "robots.txt" }); routes.MapRoute(name: "brands-all", url: "brands", defaults: new { controller = "Brand", action = "BrandList", id = UrlParameter.Optional }); routes.MapRoute(name: "brand-detail", url: "brands/{name}", defaults: new { controller = "Brand", action = "BrandDetail", id = UrlParameter.Optional }); routes.MapRoute(name: "brand-productslist", url: "brands/{name}/all", defaults: new { controller = "Brand", action = "BrandProducts", id = UrlParameter.Optional }); routes.MapRoute(name: "brand-home", url: "brands/brand-home", defaults: new { controller = "Brand", action = "BrandLanding" }); routes.MapRoute(name: "myaccount", url: "myaccount", defaults: new { controller = "Account", action = "MyAccount" }); routes.MapRoute(name: "search", url: "search", defaults: new { controller = "Search", action = "Search", id = UrlParameter.Optional }); routes.MapRoute(name: "categories-products", url: "categories/categories-products", defaults: new { controller = "Category", action = "CategoryLanding2" }); routes.MapRoute(name: "categories", url: "categories", defaults: new { controller = "Category", action = "CategoryList" }); //routes.MapRoute(name: "errorblog", url: "blog/blogs", defaults: new { controller = "Common", action = "PageNotFound", url = UrlParameter.Optional }); routes.MapRoute(name: "catalogue", url: SiteRouteUrl.Category + "/{categorySlug}/{groupSlug}/{linkSlug}/{linkSlug1}", defaults: new { controller = "Category", action = "CategoryLanding", categorySlug = UrlParameter.Optional, groupSlug = UrlParameter.Optional, linkSlug = UrlParameter.Optional, linkSlug1 = UrlParameter.Optional }); routes.MapRoute(name: "product", url: "products/{name}", defaults: new { controller = "Product", action = "ProductDetail", name = UrlParameter.Optional }); routes.MapRoute(name: "bloglisting", url: "blogs", defaults: new { controller = "Blog", action = "Blogs", url = UrlParameter.Optional }); routes.MapRoute(name: "blogs", url: "blogs/{url}", defaults: new { controller = "Blog", action = "BlogDetail", url = UrlParameter.Optional }); routes.MapRoute(name: "blog-category", url: "blog-category/{slug}/{currentpage}", defaults: new { controller = "Blog", action = "GetAllBlogsbyCategory", slug = UrlParameter.Optional, currentpage = UrlParameter.Optional }); routes.MapRoute(name: "blog-type", url: "blog-type/{slug}/{currentpage}", defaults: new { controller = "Blog", action = "GetAllBlogsByType", slug = UrlParameter.Optional, currentpage = UrlParameter.Optional }); routes.MapRoute(name: "blog-editor", url: "blog-editor/{slug}/{currentpage}", defaults: new { controller = "Blog", action = "GetAllBlogsByEditor", slug = UrlParameter.Optional, currentpage = UrlParameter.Optional }); routes.MapRoute(name: "checkout", url: "std/{basketId}", defaults: new { controller = "Checkout", action = "StandardCheckout", basketId = UrlParameter.Optional }); routes.MapRoute(name: "onepagecheckout", url: "opc/{basketId}", defaults: new { controller = "Checkout", action = "OnePageCheckout", basketId = UrlParameter.Optional }); //ROUTES FOR JD WIZARD CHECKOUT routes.MapRoute(name: "wizardcheckout", url: "wzc/{basketId}", defaults: new { controller = "Checkout", action = "WizardCheckout", basketId = UrlParameter.Optional }); routes.MapRoute(name: "wizardcheckoutdelivery", url: "wzc/delivery/{basketId}", defaults: new { controller = "Checkout", action = "WizardCheckoutDelivery", basketId = UrlParameter.Optional }); routes.MapRoute(name: "wizardcheckoutbilling", url: "wzc/billing/{basketId}", defaults: new { controller = "Checkout", action = "WizardCheckoutBilling", basketId = UrlParameter.Optional }); //ROUTES FOR HC WIZARD CHECKOUT routes.MapRoute(name: "hotelcheckout", url: "hc/{basketId}", defaults: new { controller = "Checkout", action = "HotelCheckout", basketId = UrlParameter.Optional }); routes.MapRoute(name: "hotelcheckoutdelivery", url: "hc/delivery/{basketId}", defaults: new { controller = "Checkout", action = "HotelCheckoutDelivery", basketId = UrlParameter.Optional }); routes.MapRoute(name: "hotelcheckoutbilling", url: "hc/billing/{basketId}", defaults: new { controller = "Checkout", action = "HotelCheckoutBilling", basketId = UrlParameter.Optional }); routes.MapRoute(name: "quotePayment", url: "quote/{link}", defaults: new { controller = "B2B", action = "ValidateQuotePayment", link = UrlParameter.Optional }); routes.MapRoute(name: "phoneorderPayment", url: "phoneorder/{link}", defaults: new { controller = "B2B", action = "ValidateQuotePayment", link = UrlParameter.Optional }); routes.MapRoute(name: "dynamic-list", url: "list/{slug}", defaults: new { controller = "Search", action = "DynamicListItems", slug = UrlParameter.Optional }); routes.MapRoute(name: "lookbooks", url: "lookbook", defaults: new { controller = "lookbook", action = "index", slug = UrlParameter.Optional }); routes.MapRoute(name: "lookbook", url: "lookbook/{slug}", defaults: new { controller = "lookbook", action = "LookbookDetail", slug = UrlParameter.Optional }); routes.MapRoute(name: "dynamic-page-preview", url: "ocx-preview/{id}/{versionNo}/{langCulture}", defaults: new { controller = "Page", action = "PagePreview", slug = UrlParameter.Optional, id = UrlParameter.Optional, versionNo = UrlParameter.Optional, langCulture = UrlParameter.Optional }); //routes.MapRoute(name: "dynamic-page", url: "{slug}", defaults: new { controller = "Page", action = "DynamicPage", slug = UrlParameter.Optional }); routes.MapRoute(name: "passwordrecovery", url: "passwordrecovery/{id}", defaults: new { controller = "Account", action = "PasswordRecovery", id = UrlParameter.Optional }); //Payment Method post notification route handlers routes.MapRoute(name: "MasterCardNotification", url: "checkout/mastercardnotification", defaults: new { controller = "MasterCard", action = "Notification", id = UrlParameter.Optional }); routes.MapRoute(name: "MasterCardCheck3DSecure", url: "checkout/MasterCardCheck3DSecure", defaults: new { controller = "MasterCard", action = "Check3DSecure", id = UrlParameter.Optional }); routes.MapRoute(name: "MasterCardAuthorize", url: "checkout/MasterCardAuthorize", defaults: new { controller = "MasterCard", action = "Authorize", id = UrlParameter.Optional }); routes.MapRoute(name: "Paypalnotification", url: "checkout/Paypalnotification", defaults: new { controller = "Paypal", action = "Notification", id = UrlParameter.Optional }); routes.MapRoute(name: "CODPaymentResponse", url: "checkout/PaymentResponse", defaults: new { controller = "COD", action = "PaymentResponse", id = UrlParameter.Optional }); var controllers = GetControllerNames(); foreach (var cntrl in controllers) { routes.MapRoute(name: cntrl + "default", url: cntrl + "/{action}/{id}", defaults: new { controller = cntrl, action = "index", id = UrlParameter.Optional }); } routes.MapRoute(name: "dynamic-page-3", url: "{slug}/{slug1}/{slug2}/{slug3}/{slug4}", defaults: new { controller = "Page", action = "DynamicPage", slug = UrlParameter.Optional, slug1 = UrlParameter.Optional, slug2 = UrlParameter.Optional, slug3 = UrlParameter.Optional, slug4 = UrlParameter.Optional }); routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Page", action = "DynamicPage", id = UrlParameter.Optional }); // routes.MapRoute(name: "Default1", url: "{*.*}", defaults: new { controller = "Page", action = "DynamicPage", id = UrlParameter.Optional }); }
/// <summary> /// Registers the routes. /// </summary> /// <param name="routes">The routes.</param> private void RegisterRoutes( RockContext rockContext, RouteCollection routes ) { routes.Clear(); PageRouteService pageRouteService = new PageRouteService( rockContext ); // find each page that has defined a custom routes. foreach ( PageRoute pageRoute in pageRouteService.Queryable() ) { // Create the custom route and save the page id in the DataTokens collection routes.AddPageRoute( pageRoute ); } // Add a default page route routes.Add( new Route( "page/{PageId}", new Rock.Web.RockRouteHandler() ) ); // Add a default route for when no parameters are passed routes.Add( new Route( "", new Rock.Web.RockRouteHandler() ) ); }
/// <summary> /// 重新注册所有路由 /// </summary> /// <param name="routes"></param> public static void RegisterRoutes(RouteCollection routes) { //插件路由放在默认路由前面,才能优先匹配到 using (RouteTable.Routes.GetReadLock()) { routes.Clear(); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); foreach (var item in Plugins.Values) { routes.MapRoute(item.PluginName, item.Url, item.Defaults); } routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } }
/// <summary> /// Méthode d'enregistrement des routes de l'application en fonction des pages en base de données. /// </summary> public static void RegisterRoutes(RouteCollection routes) { System.Collections.Generic.Dictionary<Object, Object> param = new System.Collections.Generic.Dictionary<object, object>(); SCYS_GEN.SCYS_GENClient s = new SCYS_GEN.SCYS_GENClient(); System.Collections.Generic.List<DB.PAGE> result = null; try { s.Open(); routes.Clear(); using (System.IO.MemoryStream mparam = DB.Serializer.WRITEC<System.Collections.Generic.Dictionary<Object, Object>>(param)) { using (System.IO.MemoryStream mresult = s.GET_PAGE(mparam)) { result = DB.Serializer.READC<System.Collections.Generic.List<DB.PAGE>>(mresult); } } if (result == null) throw new Exception(); foreach (var item in result) routes.Add(item.ROUTE_NAME, new CYS_ROUTES(item.ROUTE, new CYS_ROUTE(item.VIRTUAL))); } catch (Exception ex) { s.Abort(); throw new ApplicationException(String.Empty, ex); } finally { s.Close(); } }