public void MinRouteConstraintTests(long min, int parameterValue, bool expected)
        {
            var constraint = new MinRouteConstraint(min);
            var actual     = TestValue(constraint, parameterValue);

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var idConstraint = new MinRouteConstraint(1);

            //routes.MapLocalizedRoute("DynamicStart",
            //    "dynamiccaptcha/start",
            //    new { controller = "DynamicCaptcha", action = "CaptchaStart", numberOfImages = UrlParameter.Optional },
            //    new[] { "CAF.WebSite.Application.WebUI.MvcCaptcha" });
        }
        public void MinRouteConstraint_ApplyConstraint(long min, int parameterValue, bool expected)
        {
            // Arrange
            var constraint = new MinRouteConstraint(min);

            // Act
            var actual = ConstraintsTestHelper.TestConstraint(constraint, parameterValue);

            // Assert
            Assert.Equal(expected, actual);
        }
Example #4
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var idConstraint = new MinRouteConstraint(1);

            routes.MapLocalizedRoute("DynamicStart",
                                     "dynamiccaptcha/start",
                                     new { controller = "DynamicCaptcha", action = "CaptchaStart", numberOfImages = UrlParameter.Optional },
                                     new[] { "CAF.WebSite.Application.WebUI.DynamicCaptcha" });

            routes.MapLocalizedRoute("Image",
                                     "dynamiccaptcha/image",
                                     new { controller = "DynamicCaptcha", action = "CaptchaImage", imageIndex = UrlParameter.Optional },
                                     new[] { "CAF.WebSite.Application.WebUI.DynamicCaptcha" });

            routes.MapLocalizedRoute("Audio",
                                     "dynamiccaptcha/audio",
                                     new { controller = "DynamicCaptcha", action = "CaptchaAudio", index = UrlParameter.Optional },
                                     new[] { "CAF.WebSite.Application.WebUI.DynamicCaptcha" });
        }
Example #5
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var idConstraint = new MinRouteConstraint(1);

            var route = routes.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", area = "Admin", id = "" },
                new[] { "CAF.WebSite.Mvc.Admin.Controllers" }
                );

            route.DataTokens["area"] = "Admin";

            var routeCategory = routes.MapLocalizedRoute("CustomerProfile",
                                                         "Admin/Category/{id}",
                                                         new { controller = "Category", action = "Index", area = "Admin" },
                                                         new { id = idConstraint },
                                                         new[] { "CAF.WebSite.Mvc.Admin.Controllers" }
                                                         );

            routeCategory.DataTokens["area"] = "Admin";
        }
Example #6
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var idConstraint = new MinRouteConstraint(1);

            /* Common
             * ----------------------------------------*/

            routes.MapLocalizedRoute("HomePage",
                                     "",
                                     new { controller = "Home", action = "Index" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Register",
                                     "register/",
                                     new { controller = "Customer", action = "Register" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Login",
                                     "login/",
                                     new { controller = "Customer", action = "Login" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Logout",
                                     "logout/",
                                     new { controller = "Customer", action = "Logout" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ContactUs",
                                     "contactus",
                                     new { controller = "Home", action = "ContactUs" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ShoppingCart",
                                     "cart/",
                                     new { controller = "ShoppingCart", action = "Cart" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Wishlist",
                                     "wishlist/{customerGuid}",
                                     new { controller = "ShoppingCart", action = "Wishlist", customerGuid = UrlParameter.Optional },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("MyAccount",
                                     "customer/myaccount",
                                     new { controller = "Customer", action = "MyAccount" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Topic",
                                     "t/{SystemName}",
                                     new { controller = "Topic", action = "TopicDetails" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicPopup",
                                     "t-popup/{SystemName}",
                                     new { controller = "Topic", action = "TopicDetailsPopup" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ProductSearch",
                                     "search/",
                                     new { controller = "Catalog", action = "Search" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ProductSearchAutoComplete",
                                     "catalog/searchtermautocomplete",
                                     new { controller = "Catalog", action = "SearchTermAutoComplete" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ChangeDevice",
                                     "changedevice/{dontusemobileversion}",
                                     new { controller = "Common", action = "ChangeDevice" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ChangeCurrency",
                                     "changecurrency/{customercurrency}",
                                     new { controller = "Common", action = "CurrencySelected" },
                                     new { customercurrency = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapRoute("ChangeLanguage",
                            "changelanguage/{langid}",
                            new { controller = "Common", action = "SetLanguage" },
                            new { langid = idConstraint },
                            new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ChangeTaxType",
                                     "changetaxtype/{customertaxtype}",
                                     new { controller = "Common", action = "TaxTypeSelected" },
                                     new { customertaxtype = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            /* Catalog
             * ----------------------------------------*/

            routes.MapLocalizedRoute("ManufacturerList",
                                     "manufacturer/all/",
                                     new { controller = "Catalog", action = "ManufacturerAll" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ProductsByTag",
                                     "producttag/{productTagId}/{SeName}",
                                     new { controller = "Catalog", action = "ProductsByTag", SeName = UrlParameter.Optional },
                                     new { productTagId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ProductTagsAll",
                                     "producttag/all/",
                                     new { controller = "Catalog", action = "ProductTagsAll" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyViewedProducts",
                                     "recentlyviewedproducts/",
                                     new { controller = "Catalog", action = "RecentlyViewedProducts" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyAddedProducts",
                                     "newproducts/",
                                     new { controller = "Catalog", action = "RecentlyAddedProducts" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyAddedProductsRSS",
                                     "newproducts/rss",
                                     new { controller = "Catalog", action = "RecentlyAddedProductsRss" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CompareProducts",
                                     "compareproducts/",
                                     new { controller = "Catalog", action = "CompareProducts" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Shopping Cart
             * ----------------------------------------*/

            // add product to cart (without any attributes and options). used on catalog pages.
            routes.MapLocalizedRoute("AddProductToCartSimple",
                                     "cart/addproductsimple/{productId}",
                                     new { controller = "ShoppingCart", action = "AddProductSimple" },
                                     new { productId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            // add product to cart (with attributes and options). used on the product details pages.
            routes.MapLocalizedRoute("AddProductToCart",
                                     "cart/addproduct/{productId}/{shoppingCartTypeId}",
                                     new { controller = "ShoppingCart", action = "AddProduct" },
                                     new { productId = idConstraint, shoppingCartTypeId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Checkout
             * ----------------------------------------*/

            routes.MapLocalizedRoute("Checkout",
                                     "checkout/",
                                     new { controller = "Checkout", action = "Index" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Newsletter
             * ----------------------------------------*/

            routes.MapLocalizedRoute("NewsletterActivation",
                                     "newsletter/subscriptionactivation/{token}/{active}",
                                     new { controller = "Newsletter", action = "SubscriptionActivation" },
                                     new { token = new GuidConstraint(false) },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("SubscribeNewsletter",             // COMPAT: subscribenewsletter >> newsletter/subscribe
                                     "Newsletter/Subscribe",
                                     new { controller = "Newsletter", action = "Subscribe" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Customer
             * ----------------------------------------*/

            routes.MapLocalizedRoute("AccountActivation",
                                     "customer/activation",
                                     new { controller = "Customer", action = "AccountActivation" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CustomerProfile",
                                     "profile/{id}",
                                     new { controller = "Profile", action = "Index", id = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Blog
             * ----------------------------------------*/

            routes.MapLocalizedRoute("Blog",
                                     "blog",
                                     new { controller = "Blog", action = "List" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogByTag",
                                     "blog/tag/{tag}",
                                     new { controller = "Blog", action = "BlogByTag" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogByMonth",
                                     "blog/month/{month}",
                                     new { controller = "Blog", action = "BlogByMonth" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogRSS",
                                     "blog/rss/{languageId}",
                                     new { controller = "Blog", action = "ListRss" },
                                     new { languageId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Boards
             * ----------------------------------------*/

            routes.MapLocalizedRoute("Boards",
                                     "boards",
                                     new { controller = "Boards", action = "Index" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BoardPostCreate",
                                     "boards/postcreate/{id}/{quote}",
                                     new { controller = "Boards", action = "PostCreate", quote = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicSlug",
                                     "boards/topic/{id}/{slug}",
                                     new { controller = "Boards", action = "Topic", slug = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicSlugPaged",
                                     "boards/topic/{id}/{slug}/page/{page}",
                                     new { controller = "Boards", action = "Topic" },
                                     new { id = idConstraint, page = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumSlug",
                                     "boards/forum/{id}/{slug}",
                                     new { controller = "Boards", action = "Forum", slug = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumSlugPaged",
                                     "boards/forum/{id}/{slug}/page/{page}",
                                     new { controller = "Boards", action = "Forum" },
                                     new { id = idConstraint, page = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumGroupSlug",
                                     "boards/forumgroup/{id}/{slug}",
                                     new { controller = "Boards", action = "ForumGroup", slug = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BoardSearch",
                                     "boards/search",
                                     new { controller = "Boards", action = "Search" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Misc
             * ----------------------------------------*/

            routes.MapLocalizedRoute("RegisterResult",
                                     "registerresult/{resultId}",
                                     new { controller = "Customer", action = "RegisterResult" },
                                     new { resultId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("PrivateMessages",
                                     "privatemessages/{tab}",
                                     new { controller = "PrivateMessages", action = "Index", tab = UrlParameter.Optional },
                                     new { tab = @"inbox|sent" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("NewsArchive",
                                     "news",
                                     new { controller = "News", action = "List" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("NewsRss",
                                     "news/rss/{languageId}",
                                     new { controller = "News", action = "rss", languageId = UrlParameter.Optional },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Sitemap",
                                     "sitemap",
                                     new { controller = "Home", action = "Sitemap" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("SitemapSEO",
                                     "sitemap.xml",
                                     new { controller = "Home", action = "SitemapSeo" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("StoreClosed",
                                     "storeclosed",
                                     new { controller = "Home", action = "StoreClosed" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapRoute("robots.txt",
                            "robots.txt",
                            new { controller = "Common", action = "RobotsTextFile" },
                            new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Settings",
                                     "settings",
                                     new { controller = "Common", action = "Settings" },
                                     new[] { "SmartStore.Web.Controllers" });
        }
Example #7
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var idConstraint = new MinRouteConstraint(1);

            /* Media
             * ----------------------------------------*/

            // By default IIS handles requests for static files (through its static file handler, even if they don't exist physically), but we don't want that.
            // Registering the following patterns ensures that MVC catches this requests and passes them to our media controller.
            // Within this controller we gonna find the actual file and stream it back to the client,
            // or - in case of blob storage - redirect the client to the computed public url.

            var mediaPublicPath = MediaFileSystem.GetMediaPublicPath();

            Route RegisterMediaRoute(string routeName, string actionName, string url)
            {
                return(routes.MapRoute(routeName,
                                       mediaPublicPath + url + "/{*path}",
                                       new { controller = "Media", action = actionName },
                                       new[] { "SmartStore.Web.Controllers" }));
            }

            #region V3 Media legacy routes

            //// Match URL pattern /{pub}/image/{id}/{path}[?{query}], e.g. '/media/image/234/myproduct.png?size=250'
            //SmartUrlRoutingModule.RegisterRoutablePath(@"/{0}image/([1-9]\d*|0)/.*?$".FormatInvariant(mediaPublicPath), "GET|HEAD");
            //routes.MapRoute("Image",
            //	mediaPublicPath + "image/{id}/{*name}",
            //	new { controller = "Media", action = "Image" },
            //	//new { id = new MinRouteConstraint(0) }, // Don't bother with this, the Regex matches this already
            //	new[] { "SmartStore.Web.Controllers" });

            #endregion

            #region Media routes

            // Legacy URL redirection: match URL pattern /{pub}/uploaded/{path}[?{query}], e.g. '/media/uploaded/subfolder/image.png'
            SmartUrlRoutingModule.RegisterRoutablePath(@"/{0}uploaded/.*?$".FormatInvariant(mediaPublicPath), "GET|HEAD");
            RegisterMediaRoute("MediaUploaded", "Uploaded", "uploaded");

            // Legacy tenant URL redirection: match URL pattern /{pub}/{tenant}/uploaded/{path}[?{query}], e.g. '/media/default/uploaded/subfolder/image.png'
            var str = DataSettings.Current.TenantName + "/uploaded";
            SmartUrlRoutingModule.RegisterRoutablePath(@"/{0}{1}/.*?$".FormatInvariant(mediaPublicPath, str), "GET|HEAD");
            RegisterMediaRoute("MediaUploadedWithTenant", "Uploaded", str);

            // Legacy media URL redirection: /{pub}/image/{id}/{path}[?{query}], e.g. '/media/image/234/myproduct.png?size=250'
            SmartUrlRoutingModule.RegisterRoutablePath(@"/{0}image/([1-9]\d*|0)/.*?$".FormatInvariant(mediaPublicPath), "GET|HEAD");
            RegisterMediaRoute("MediaImage", "Image", "image");

            // Match URL pattern /{pub}/media/{id}/{path}[?{query}], e.g. '/media/234/{album}/myproduct.png?size=250'
            SmartUrlRoutingModule.RegisterRoutablePath(@"/{0}[0-9]*/.*?$".FormatInvariant(mediaPublicPath), "GET|HEAD");
            RegisterMediaRoute("Media", "File", "{id}");

            #endregion


            /* Common
             * ----------------------------------------*/

            routes.MapLocalizedRoute("HomePage",
                                     "",
                                     new { controller = "Home", action = "Index" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Register",
                                     "register/",
                                     new { controller = "Customer", action = "Register" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Login",
                                     "login/",
                                     new { controller = "Customer", action = "Login" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Logout",
                                     "logout/",
                                     new { controller = "Customer", action = "Logout" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ContactUs",
                                     "contactus",
                                     new { controller = "Home", action = "ContactUs" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ShoppingCart",
                                     "cart/",
                                     new { controller = "ShoppingCart", action = "Cart" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Wishlist",
                                     "wishlist/{customerGuid}",
                                     new { controller = "ShoppingCart", action = "Wishlist", customerGuid = UrlParameter.Optional },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicLegacy",
                                     "t/{SystemName}",
                                     new { controller = "Topic", action = "TopicDetailsLegacy" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Search",
                                     "search/",
                                     new { controller = "Search", action = "Search" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("InstantSearch",
                                     "instantsearch",
                                     new { controller = "Search", action = "InstantSearch" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ChangeCurrency",
                                     "changecurrency/{customercurrency}",
                                     new { controller = "Common", action = "CurrencySelected" },
                                     new { customercurrency = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapRoute("ChangeLanguage",
                            "changelanguage/{langid}",
                            new { controller = "Common", action = "SetLanguage" },
                            new { langid = idConstraint },
                            new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ChangeTaxType",
                                     "changetaxtype/{customertaxtype}",
                                     new { controller = "Common", action = "TaxTypeSelected" },
                                     new { customertaxtype = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Catalog
             * ----------------------------------------*/

            routes.MapLocalizedRoute("ManufacturerList",
                                     "manufacturer/all/",
                                     new { controller = "Catalog", action = "ManufacturerAll" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ProductsByTag",
                                     "producttag/{productTagId}/{*path}",
                                     new { controller = "Catalog", action = "ProductsByTag" },
                                     new { productTagId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ProductTagsAll",
                                     "producttag/all/",
                                     new { controller = "Catalog", action = "ProductTagsAll" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyViewedProducts",
                                     "recentlyviewedproducts/",
                                     new { controller = "Catalog", action = "RecentlyViewedProducts" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyAddedProducts",
                                     "newproducts/",
                                     new { controller = "Catalog", action = "RecentlyAddedProducts" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyAddedProductsRSS",
                                     "newproducts/rss",
                                     new { controller = "Catalog", action = "RecentlyAddedProductsRss" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CompareProducts",
                                     "compareproducts/",
                                     new { controller = "Catalog", action = "CompareProducts" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CookieManager",
                                     "cookiemanager/",
                                     new { controller = "Common", action = "CookieManager" },
                                     new[] { "SmartStore.Web.Controllers" });

            /* Shopping Cart
             * ----------------------------------------*/

            // add product to cart (without any attributes and options). used on catalog pages.
            routes.MapLocalizedRoute("AddProductToCartSimple",
                                     "cart/addproductsimple/{productId}",
                                     new { controller = "ShoppingCart", action = "AddProductSimple" },
                                     new { productId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            // add product to cart (with attributes and options). used on the product details pages.
            routes.MapLocalizedRoute("AddProductToCart",
                                     "cart/addproduct/{productId}/{shoppingCartTypeId}",
                                     new { controller = "ShoppingCart", action = "AddProduct" },
                                     new { productId = idConstraint, shoppingCartTypeId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Checkout
             * ----------------------------------------*/

            routes.MapLocalizedRoute("Checkout",
                                     "checkout/",
                                     new { controller = "Checkout", action = "Index" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Newsletter
             * ----------------------------------------*/

            routes.MapLocalizedRoute("NewsletterActivation",
                                     "newsletter/subscriptionactivation/{token}/{active}",
                                     new { controller = "Newsletter", action = "SubscriptionActivation" },
                                     new { token = new GuidConstraint(false) },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("SubscribeNewsletter",             // COMPAT: subscribenewsletter >> newsletter/subscribe
                                     "Newsletter/Subscribe",
                                     new { controller = "Newsletter", action = "Subscribe" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Customer
             * ----------------------------------------*/

            routes.MapLocalizedRoute("AccountActivation",
                                     "customer/activation",
                                     new { controller = "Customer", action = "AccountActivation" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CustomerProfile",
                                     "profile/{id}",
                                     new { controller = "Profile", action = "Index", id = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Blog
             * ----------------------------------------*/

            routes.MapLocalizedRoute("Blog",
                                     "blog",
                                     new { controller = "Blog", action = "List" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogByTag",
                                     "blog/tag/{tag}",
                                     new { controller = "Blog", action = "BlogByTag" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogByMonth",
                                     "blog/month/{month}",
                                     new { controller = "Blog", action = "BlogByMonth" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogRSS",
                                     "blog/rss/{languageId}",
                                     new { controller = "Blog", action = "ListRss", languageId = UrlParameter.Optional },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Boards
             * ----------------------------------------*/

            routes.MapLocalizedRoute("Boards",
                                     "boards",
                                     new { controller = "Boards", action = "Index" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BoardPostCreate",
                                     "boards/postcreate/{id}/{quote}",
                                     new { controller = "Boards", action = "PostCreate", quote = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicSlug",
                                     "boards/topic/{id}/{slug}",
                                     new { controller = "Boards", action = "Topic", slug = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicSlugPaged",
                                     "boards/topic/{id}/{slug}/page/{page}",
                                     new { controller = "Boards", action = "Topic" },
                                     new { id = idConstraint, page = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumSlug",
                                     "boards/forum/{id}/{slug}",
                                     new { controller = "Boards", action = "Forum", slug = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumSlugPaged",
                                     "boards/forum/{id}/{slug}/page/{page}",
                                     new { controller = "Boards", action = "Forum" },
                                     new { id = idConstraint, page = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumGroupSlug",
                                     "boards/forumgroup/{id}/{slug}",
                                     new { controller = "Boards", action = "ForumGroup", slug = UrlParameter.Optional },
                                     new { id = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BoardSearch",
                                     "boards/search",
                                     new { controller = "Boards", action = "Search" },
                                     new[] { "SmartStore.Web.Controllers" });


            /* Misc
             *          ----------------------------------------*/

            routes.MapLocalizedRoute("RegisterResult",
                                     "registerresult/{resultId}",
                                     new { controller = "Customer", action = "RegisterResult" },
                                     new { resultId = idConstraint },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("PrivateMessages",
                                     "privatemessages/{tab}",
                                     new { controller = "PrivateMessages", action = "Index", tab = UrlParameter.Optional },
                                     new { tab = @"inbox|sent" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("NewsArchive",
                                     "news",
                                     new { controller = "News", action = "List" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("NewsRss",
                                     "news/rss/{languageId}",
                                     new { controller = "News", action = "rss", languageId = UrlParameter.Optional },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Sitemap",
                                     "sitemap",
                                     new { controller = "Home", action = "Sitemap" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("XmlSitemap",
                                     "sitemap.xml",
                                     new { controller = "Media", action = "XmlSitemap" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("StoreClosed",
                                     "storeclosed",
                                     new { controller = "Home", action = "StoreClosed" },
                                     new[] { "SmartStore.Web.Controllers" });

            routes.MapRoute("robots.txt",
                            "robots.txt",
                            new { controller = "Common", action = "RobotsTextFile" },
                            new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Settings",
                                     "settings",
                                     new { controller = "Common", action = "Settings" },
                                     new[] { "SmartStore.Web.Controllers" });
        }
 private static void ApplyMinRouteConstraint(OpenApiSchema schema, MinRouteConstraint minRouteConstraint)
 => schema.Minimum = minRouteConstraint.Min;
        public void RegisterRoutes(RouteCollection routes)
        {
			var idConstraint = new MinRouteConstraint(1);
			
			/* Common
			----------------------------------------*/
			
            routes.MapLocalizedRoute("HomePage",
				"",
				new { controller = "Home", action = "Index"},
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("Register",
				"register/",
				new { controller = "Customer", action = "Register" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("Login",
				"login/",
				new { controller = "Customer", action = "Login" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("Logout",
				"logout/",
				new { controller = "Customer", action = "Logout" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ContactUs",
				"contactus",
				new { controller = "Home", action = "ContactUs" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ShoppingCart",
				"cart/",
				new { controller = "ShoppingCart", action = "Cart" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("Wishlist",
				"wishlist/{customerGuid}",
				new { controller = "ShoppingCart", action = "Wishlist", customerGuid = UrlParameter.Optional },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("MyAccount",
				"customer/myaccount",
				new { controller = "Customer", action = "MyAccount" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("Topic",
				"t/{SystemName}",
				new { controller = "Topic", action = "TopicDetails" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("TopicPopup",
				"t-popup/{SystemName}",
				new { controller = "Topic", action = "TopicDetailsPopup" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ProductSearch",
				"search/",
				new { controller = "Catalog", action = "Search" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ProductSearchAutoComplete",
				"catalog/searchtermautocomplete",
				new { controller = "Catalog", action = "SearchTermAutoComplete" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ChangeDevice",
				"changedevice/{dontusemobileversion}",
				new { controller = "Common", action = "ChangeDevice" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ChangeCurrency",
				"changecurrency/{customercurrency}",
				new { controller = "Common", action = "CurrencySelected" },
				new { customercurrency = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapRoute("ChangeLanguage",
				"changelanguage/{langid}",
				new { controller = "Common", action = "SetLanguage" },
				new { langid = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ChangeTaxType",
				"changetaxtype/{customertaxtype}",
				new { controller = "Common", action = "TaxTypeSelected" },
				new { customertaxtype = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

			/* Catalog
			----------------------------------------*/

			routes.MapLocalizedRoute("ManufacturerList",
				"manufacturer/all/",
				new { controller = "Catalog", action = "ManufacturerAll" },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ProductsByTag",
				"producttag/{productTagId}/{SeName}",
				new { controller = "Catalog", action = "ProductsByTag", SeName = UrlParameter.Optional },
				new { productTagId = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ProductTagsAll",
				"producttag/all/",
				new { controller = "Catalog", action = "ProductTagsAll" },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyViewedProducts",
                "recentlyviewedproducts/",
				new { controller = "Catalog", action = "RecentlyViewedProducts" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyAddedProducts",
                "newproducts/",
				new { controller = "Catalog", action = "RecentlyAddedProducts" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("RecentlyAddedProductsRSS",
                "newproducts/rss",
				new { controller = "Catalog", action = "RecentlyAddedProductsRss" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CompareProducts",
                "compareproducts/",
				new { controller = "Catalog", action = "CompareProducts" },
                new[] { "SmartStore.Web.Controllers" });


			/* Shopping Cart
			----------------------------------------*/

			// add product to cart (without any attributes and options). used on catalog pages.
			routes.MapLocalizedRoute("AddProductToCartSimple",
				"cart/addproductsimple/{productId}",
				new { controller = "ShoppingCart", action = "AddProductSimple" },
				new { productId = idConstraint },
                new[] { "SmartStore.Web.Controllers" });

            // add product to cart (with attributes and options). used on the product details pages.
			routes.MapLocalizedRoute("AddProductToCart",
				"cart/addproduct/{productId}/{shoppingCartTypeId}",
				new { controller = "ShoppingCart", action = "AddProduct" },
				new { productId = idConstraint, shoppingCartTypeId = idConstraint },
                new[] { "SmartStore.Web.Controllers" });


			/* Checkout
			----------------------------------------*/

            routes.MapLocalizedRoute("Checkout",
                "checkout/",
                new { controller = "Checkout", action = "Index" },
                new[] { "SmartStore.Web.Controllers" });


			/* Newsletter
			----------------------------------------*/

            routes.MapLocalizedRoute("NewsletterActivation",
                "newsletter/subscriptionactivation/{token}/{active}",
                new { controller = "Newsletter", action = "SubscriptionActivation" },
                new { token = new GuidConstraint(false) },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("SubscribeNewsletter", // COMPAT: subscribenewsletter >> newsletter/subscribe
                "Newsletter/Subscribe",
				new { controller = "Newsletter", action = "Subscribe" },
                new[] { "SmartStore.Web.Controllers" });


			/* Customer
			----------------------------------------*/

            routes.MapLocalizedRoute("AccountActivation",
                "customer/activation",
                new { controller = "Customer", action = "AccountActivation" },                            
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("CustomerProfile",
                "profile/{id}",
                new { controller = "Profile", action = "Index", id = UrlParameter.Optional },
				new { id = idConstraint },
                new[] { "SmartStore.Web.Controllers" });


			/* Blog
			----------------------------------------*/

            routes.MapLocalizedRoute("Blog",
                "blog",
                new { controller = "Blog", action = "List" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogByTag",
                "blog/tag/{tag}",
                new { controller = "Blog", action = "BlogByTag" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogByMonth",
                "blog/month/{month}",
                new { controller = "Blog", action = "BlogByMonth" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BlogRSS",
                "blog/rss/{languageId}",
                new { controller = "Blog", action = "ListRss" },
				new { languageId = idConstraint },
                new[] { "SmartStore.Web.Controllers" });


			/* Boards
			----------------------------------------*/

            routes.MapLocalizedRoute("Boards",
                "boards",
                new { controller = "Boards", action = "Index" },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("BoardPostCreate",
				"boards/postcreate/{id}/{quote}",
				new { controller = "Boards", action = "PostCreate", quote = UrlParameter.Optional },
				new { id = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("TopicSlug",
                "boards/topic/{id}/{slug}",
                new { controller = "Boards", action = "Topic", slug = UrlParameter.Optional },
				new { id = idConstraint },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("TopicSlugPaged",
				"boards/topic/{id}/{slug}/page/{page}",
				new { controller = "Boards", action = "Topic" },
				new { id = idConstraint, page = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumSlug",
                "boards/forum/{id}/{slug}",
                new { controller = "Boards", action = "Forum", slug = UrlParameter.Optional },
				new { id = idConstraint },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("ForumSlugPaged",
				"boards/forum/{id}/{slug}/page/{page}",
				new { controller = "Boards", action = "Forum" },
				new { id = idConstraint, page = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("ForumGroupSlug",
				"boards/forumgroup/{id}/{slug}",
				new { controller = "Boards", action = "ForumGroup", slug = UrlParameter.Optional },
				new { id = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("BoardSearch",
                "boards/search",
                new { controller = "Boards", action = "Search" },
                new[] { "SmartStore.Web.Controllers" });


			/* Misc
			----------------------------------------*/

			routes.MapLocalizedRoute("RegisterResult",
				"registerresult/{resultId}",
				new { controller = "Customer", action = "RegisterResult" },
				new { resultId = idConstraint },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("PrivateMessages",
                "privatemessages/{tab}",
                new { controller = "PrivateMessages", action = "Index", tab = UrlParameter.Optional },
				new { tab = @"inbox|sent" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("NewsArchive",
                "news",
                new { controller = "News", action = "List" },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("NewsRss",
				"news/rss/{languageId}",
				new { controller = "News", action = "rss", languageId = UrlParameter.Optional },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("Sitemap",
                "sitemap",
                new { controller = "Home", action = "Sitemap" },
                new[] { "SmartStore.Web.Controllers" });

            routes.MapLocalizedRoute("SitemapSEO",
                "sitemap.xml",
				new { controller = "Home", action = "SitemapSeo" },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("StoreClosed",
				"storeclosed",
				new { controller = "Home", action = "StoreClosed" },
				new[] { "SmartStore.Web.Controllers" });

            routes.MapRoute("robots.txt",
                "robots.txt",
                new { controller = "Common", action = "RobotsTextFile" },
                new[] { "SmartStore.Web.Controllers" });

			routes.MapLocalizedRoute("Settings",
				"settings",
				new { controller = "Common", action = "Settings" },
				new[] { "SmartStore.Web.Controllers" });

        }
Example #10
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var idConstraint = new MinRouteConstraint(1);

            /* Common
             * ----------------------------------------*/

            routes.MapLocalizedRoute("HomePage",
                                     "",
                                     new { controller = "Home", action = "Index" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Register",
                                     "register/",
                                     new { controller = "Member", action = "Register" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Login",
                                     "login/",
                                     new { controller = "Member", action = "Login" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ContactUs",
                                     "contactus",
                                     new { controller = "Home", action = "ContactUs" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Feedback",
                                     "feedback",
                                     new { controller = "Home", action = "Feedback" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Logout",
                                     "logout/",
                                     new { controller = "Member", action = "Logout" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Topic",
                                     "t/{SystemName}",
                                     new { controller = "Topic", action = "TopicDetails" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("TopicPopup",
                                     "t-popup/{SystemName}",
                                     new { controller = "Topic", action = "TopicDetailsPopup" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ChangeDevice",
                                     "changedevice/{dontusemobileversion}",
                                     new { controller = "Common", action = "ChangeDevice" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });


            routes.MapRoute("ChangeLanguage",
                            "changelanguage/{langid}",
                            new { controller = "Common", action = "SetLanguage" },
                            new { langid = idConstraint },
                            new[] { "CAF.WebSite.Mvc.Controllers" });

            /* Newsletter
             * ----------------------------------------*/
            routes.MapLocalizedRoute("NewsletterActivation",
                                     "newsletter/subscriptionactivation/{token}/{active}",
                                     new { controller = "Newsletter", action = "SubscriptionActivation" },
                                     new { token = new GuidConstraint(false) },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("SubscribeNewsletter", // COMPAT: subscribenewsletter >> newsletter/subscribe
                                     "Newsletter/Subscribe",
                                     new { controller = "Newsletter", action = "Subscribe" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ArticleSearch",
                                     "search/",
                                     new { controller = "ArticleCatalog", action = "Search" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ArticleSearchAutoComplete",
                                     "ArticleCatalog/searchtermautocomplete",
                                     new { controller = "ArticleCatalog", action = "SearchTermAutoComplete" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ArticlesByTag",
                                     "articlestag/{articleTagId}/{SeName}",
                                     new { controller = "ArticleCatalog", action = "ArticlesByTag", SeName = UrlParameter.Optional },
                                     new { articleTagId = idConstraint },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ArticleTagsAll",
                                     "articletag/all/",
                                     new { controller = "ArticleCatalog", action = "ArticlesTagsAll" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("ClientList",
                                     "client/all/",
                                     new { controller = "ArticleCatalog", action = "ClientAll" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });



            /* Misc
             * ----------------------------------------*/

            routes.MapLocalizedRoute("RegisterResult",
                                     "registerresult/{resultId}",
                                     new { controller = "Member", action = "RegisterResult" },
                                     new { resultId = idConstraint },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Sitemap",
                                     "sitemap",
                                     new { controller = "Home", action = "Sitemap" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("SitemapSEO",
                                     "sitemap.xml",
                                     new { controller = "Home", action = "SitemapSeo" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });
            routes.MapLocalizedRoute("SiteClosed",
                                     "siteclosed",
                                     new { controller = "Home", action = "SiteClosed" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapRoute("robots.txt",
                            "robots.txt",
                            new { controller = "Common", action = "RobotsTextFile" },
                            new[] { "CAF.WebSite.Mvc.Controllers" });

            routes.MapLocalizedRoute("Settings",
                                     "settings",
                                     new { controller = "Common", action = "Settings" },
                                     new[] { "CAF.WebSite.Mvc.Controllers" });


            routes.MapLocalizedRoute("Captcha",
                                     "Captcha/",
                                     new { controller = "DefaultCaptcha", action = "Generate" },
                                     new[] { "CaptchaMvc.Controllers" });

            routes.MapLocalizedRoute("RefreshCaptcha",
                                     "RefreshCaptcha/",
                                     new { controller = "DefaultCaptcha", action = "Refresh" },
                                     new[] { "CaptchaMvc.Controllers" });
        }