Exemplo n.º 1
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.RouteExistingFiles = true;
            routes.MapMvcAttributeRoutes();

            //routes.MapRoute("Diskfile", "Content/StaticContent.html", new {controller = "Customer", action = "List"});
            routes.IgnoreRoute("Content/{filename}.html");

            routes.Add(new Route("sayhello", new CustomRouteHandler()));

            routes.Add(new LegacyRoute(
                "~/article/windows_31_Overview.html",
                "~/old/.net_10_class_library"
                ));

            routes.MapRoute("myroute", "{controller}/{action}",null,new []
            {
                "UrlAndRoutes.Controllers"
            });
            routes.MapRoute("myotherroute", "App/{action}",
                new { controller = "Home" }, new[]
            {
                "UrlAndRoutes.Controllers"
            });
        }
Exemplo n.º 2
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add(new Route("{lang}/{controller}/{action}/{id}",
                            new RouteValueDictionary(new
                            {
                                lang = "zh-CN",
                                controller = "Home",
                                action = "Index",
                                id = UrlParameter.Optional
                            }),
                            new RouteValueDictionary(new
                            {
                                lang = "(zh-CN)|(en-US)"
                            }),
                            new MutiLangRouteHandler()));

            routes.Add(new Route("{controller}/{action}/{id}",
                            new RouteValueDictionary(new
                            {
                                lang = "zh-CN",
                                controller = "Home",
                                action = "Index",
                                id = UrlParameter.Optional
                            }), new MutiLangRouteHandler()));

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { lang = "en-US", controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);
        }
Exemplo n.º 3
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add("DomainTenantRoute", new DomainRoute(
                "{tenant}.testdomin.com",     // Domain with parameters
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, tenant = UrlParameter.Optional}  // Parameter defaults
            ));

            routes.Add("DomainTenantCatalogueRoute", new DomainRoute(
                "{tenant}-cat_{catalogue}.testdomin.com",     // Domain with parameters
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, tenant = UrlParameter.Optional, catalogue = UrlParameter.Optional }  // Parameter defaults
            ));

            routes.Add("DomainTenantStyleRoute", new DomainRoute(
                "{tenant}-style_{style}.testdomin.com",     // Domain with parameters
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, tenant = UrlParameter.Optional, style = UrlParameter.Optional }  // Parameter defaults
            ));

            routes.Add("DomainTenantCatalogueStyleRoute", new DomainRoute(
                "{tenant}-cat_{catalogue}-style_{style}.testdomin.com",     // Domain with parameters
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, tenant = UrlParameter.Optional, catalogue = UrlParameter.Optional, style = UrlParameter.Optional }  // Parameter defaults
            ));

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }
Exemplo n.º 4
0
        private static HtmlHelper GetFormHelper(string formOpenTagExpectation, string formCloseTagExpectation, out Mock<HttpResponseBase> mockHttpResponse) {
            Mock<HttpRequestBase> mockHttpRequest = new Mock<HttpRequestBase>();
            mockHttpRequest.Expect(r => r.Url).Returns(new Uri("http://www.contoso.com/some/path"));
            mockHttpResponse = new Mock<HttpResponseBase>(MockBehavior.Strict);
            mockHttpResponse.Expect(r => r.Write(formOpenTagExpectation)).Verifiable();

            if (!String.IsNullOrEmpty(formCloseTagExpectation)) {
                mockHttpResponse.Expect(r => r.Write(formCloseTagExpectation)).AtMostOnce().Verifiable();
            }

            mockHttpResponse.Expect(r => r.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(r => AppPathModifier + r);
            Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();
            mockHttpContext.Expect(c => c.Request).Returns(mockHttpRequest.Object);
            mockHttpContext.Expect(c => c.Response).Returns(mockHttpResponse.Object);
            RouteCollection rt = new RouteCollection();
            rt.Add(new Route("{controller}/{action}/{id}", null) { Defaults = new RouteValueDictionary(new { id = "defaultid" }) });
            rt.Add("namedroute", new Route("named/{controller}/{action}/{id}", null) { Defaults = new RouteValueDictionary(new { id = "defaultid" }) });
            RouteData rd = new RouteData();
            rd.Values.Add("controller", "home");
            rd.Values.Add("action", "oldaction");

            Mock<ViewContext> mockViewContext = new Mock<ViewContext>();
            mockViewContext.Expect(c => c.HttpContext).Returns(mockHttpContext.Object);
            mockViewContext.Expect(c => c.RouteData).Returns(rd);

            HtmlHelper helper = new HtmlHelper(
                mockViewContext.Object,
                new Mock<IViewDataContainer>().Object,
                rt);
            return helper;
        }
Exemplo n.º 5
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            MetaModel model = new MetaModel();
            model.RegisterContext(() => new YAWAMT.DataClassesDataContext(new Config().ConnectionString), new ContextConfiguration() { ScaffoldAllTables = false });

            routes.Add(new DynamicDataRoute("Data/{table}/ListDetails.aspx")
            {
                Action = PageAction.List,
                ViewName = "ListDetails",
                Model = model
            });
            routes.Add(new DynamicDataRoute("Data/{table}/ListDetails.aspx")
            {
                Action = PageAction.Details,
                ViewName = "ListDetails",
                Model = model
            });

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.Add(new DynamicDataRoute("Data/{table}/{action}.aspx")
            //{
            //    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
            //    Model = model
            //});

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );
        }
Exemplo n.º 6
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.Add(new Route("SayHello", new CustomRouteHandler()));

            routes.Add(new LegacyRoute(
            "~/articles/Windows_3.1_Overview.html",
            "~/old/.NET_1.0_Class_Library"));

            routes.MapRoute("MyRoute", "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional });

            //routes.RouteExistingFiles = true;

            //routes.MapRoute("DiskFile", "Content/StaticContent.html",
            //    new {
            //        controller = "Account", action = "LogOn",
            //    },
            //    new {
            //        customConstraint = new UserAgentConstraint("IE")
            //    });

            //routes.IgnoreRoute("Content/{filename}.html");

            //routes.MapRoute("", "{controller}/{action}");

            //routes.MapRoute("MyRoute", "{controller}/{action}/{id}/{*catchall}",
            //    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            //    new {
            //        controller = "^H.*", action = "Index|About",
            //        httpMethod = new HttpMethodConstraint("GET", "POST"),
            //        customConstraint = new UserAgentConstraint("IE")
            //    },
            //    new[] { "URLsAndRoutes.Controllers" });
        }
Exemplo n.º 7
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Product", // Route name
                "Product/{id}", // URL with parameters
                new { controller = "Product", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "ProductAsync", // Route name
                "ProductAsync/{id}", // URL with parameters
                new { controller = "ProductAsync", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

            // Edit the base address of Service1 by replacing the "Service1" string below
            routes.Add(new ServiceRoute("WCFService/Product", new WebServiceHostFactory(), typeof(ProductService)));
            routes.Add(new ServiceRoute("WCFService/ProductAsync", new WebServiceHostFactory(), typeof(ProductAsyncService)));

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }
Exemplo n.º 8
0
		public void AddDuplicateEmpty ()
		{
			var c = new RouteCollection ();
			// when name is "", no duplicate check is done.
			c.Add ("", new Route (null, null));
			c.Add ("", new Route (null, null));
		}
        public static void RegisterModelRoutes(RouteCollection routes, MetaModel model, string prefix, bool useSeperatePages) {
            if (useSeperatePages) {
                // The following statement supports separate-page mode, where the List, Detail, Insert, and 
                // Update tasks are performed by using separate pages. To enable this mode, uncomment the following 
                // route definition, and comment out the route definitions in the combined-page mode section that follows.
                routes.Add(new DynamicDataRoute(prefix + "/{table}/{action}.aspx") {
                    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                    Model = model
                });
            } else {

                // The following statements support combined-page mode, where the List, Detail, Insert, and
                // Update tasks are performed by using the same page. To enable this mode, uncomment the
                // following routes and comment out the route definition in the separate-page mode section above.
                routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
                    Action = PageAction.List,
                    ViewName = "ListDetails",
                    Model = model
                });

                routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
                    Action = PageAction.Details,
                    ViewName = "ListDetails",
                    Model = model
                });
            }
        }
Exemplo n.º 10
0
		public void AddNullMame ()
		{
			var c = new RouteCollection ();
			// when name is null, no duplicate check is done.
			c.Add (null, new Route (null, null));
			c.Add (null, new Route (null, null));
		}
Exemplo n.º 11
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            const string defautlRouteUrl = "{controller}/{action}/{id}";

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            RouteValueDictionary defaultRouteValueDictionary = new RouteValueDictionary(new { controller = "Home", action = "Index", id = UrlParameter.Optional });
            routes.Add("DefaultGlobalised", new GlobalisedRoute(defautlRouteUrl, defaultRouteValueDictionary));
            routes.Add("Default", new Route(defautlRouteUrl, defaultRouteValueDictionary, new MvcRouteHandler()));

            //LocalizedViewEngine: this is to support views also when named e.g. Index.de.cshtml
            routes.MapRoute(
                "Default2",
                "{culture}/{controller}/{action}/{id}",
                new
                {
                    culture = "en",
                    controller = "Home",//ControllerName
                    action = "Index",//ActionName
                    id = UrlParameter.Optional
                }
            ).RouteHandler = new LocalizedMvcRouteHandler();


            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);
        }
Exemplo n.º 12
0
        public static void RegisterRoutes(RouteCollection routes, IDependencyInjectionContainer container)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // TODO: Make custom FavIcons per tenant
            routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

            routes.MapRoute(
                name: "Error - 404",
                url: "not-found",
                defaults: new { controller = "System", action = "Status404" }
                );

            routes.MapRoute(
                name: "Error - 500",
                url: "server-error",
                defaults: new { controller = "System", action = "Status500" }
                );

            routes.Add(container.Resolve<LowercaseRedirectRoute>());
            routes.Add(container.Resolve<TrailingSlashRedirectRoute>());
            routes.Add(container.Resolve<DefaultLocaleRedirectRoute>());
            routes.Add("Page", container.Resolve<PageRoute>());
            routes.Add("Product", container.Resolve<ProductRoute>());

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
Exemplo n.º 13
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            string sRoute = ConfigurationSettings.AppSettings["fonts.route"] ?? "fonts/";
            routes.Add(new Route(sRoute + "native/{fontname}", new FontServiceRoute()));
            routes.Add(new Route(sRoute + "js/{fontname}", new FontServiceRoute()));
			routes.Add(new Route(sRoute + "odttf/{fontname}", new FontServiceRoute()));
        }
Exemplo n.º 14
0
        private static HtmlHelper GetFormHelper(out StringWriter writer) {
            Mock<HttpRequestBase> mockHttpRequest = new Mock<HttpRequestBase>();
            mockHttpRequest.Setup(r => r.Url).Returns(new Uri("http://www.contoso.com/some/path"));
            Mock<HttpResponseBase> mockHttpResponse = new Mock<HttpResponseBase>(MockBehavior.Strict);

            mockHttpResponse.Setup(r => r.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(r => AppPathModifier + r);
            Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();
            mockHttpContext.Setup(c => c.Request).Returns(mockHttpRequest.Object);
            mockHttpContext.Setup(c => c.Response).Returns(mockHttpResponse.Object);
            RouteCollection rt = new RouteCollection();
            rt.Add(new Route("{controller}/{action}/{id}", null) { Defaults = new RouteValueDictionary(new { id = "defaultid" }) });
            rt.Add("namedroute", new Route("named/{controller}/{action}/{id}", null) { Defaults = new RouteValueDictionary(new { id = "defaultid" }) });
            RouteData rd = new RouteData();
            rd.Values.Add("controller", "home");
            rd.Values.Add("action", "oldaction");

            Mock<ViewContext> mockViewContext = new Mock<ViewContext>();
            mockViewContext.Setup(c => c.HttpContext).Returns(mockHttpContext.Object);
            mockViewContext.Setup(c => c.RouteData).Returns(rd);
            writer = new StringWriter();
            mockViewContext.Setup(c => c.Writer).Returns(writer);

            HtmlHelper helper = new HtmlHelper(
                mockViewContext.Object,
                new Mock<IViewDataContainer>().Object,
                rt);
            return helper;
        }
Exemplo n.º 15
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add("SysAdminRoute", new DomainRoute(
                       "indignado.4c7.net",     // Domain with parameters
                       "admin/{action}/{id}",    // URL with parameters
                       new { controller = "SysAdmin", action = "LogOn", id = "" }  // Parameter defaults
                    ));

            routes.Add("SubDomainRoute", new DomainRoute(
                       "{movimiento}.4c7.net",     // Domain with parameters
                       "{controller}/{action}/{id}",    // URL with parameters
                       new { movimiento = "default", controller = "Home", action = "Index", id = "" }  // Parameter defaults
                    ));

            routes.Add("SubDomain2Route", new DomainRoute(
                       "{movimiento}.indignado.4c7.net",     // Domain with parameters
                       "{controller}/{action}/{id}",    // URL with parameters
                       new { movimiento = "default", controller = "Home", action = "Index", id = "" }  // Parameter defaults
                    ));

            /*
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );*/
        }
        public static void RegisterRoutes(RouteCollection routes) {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Redirect From Old Route to New route
            var targetRoute = routes.Map("target", "yo/{id}/{action}", new { controller = "Home" });
            routes.Redirect(r => r.MapRoute("legacy", "foo/{id}/baz/{action}")).To(targetRoute, new { id = "123", action = "index" });
            routes.Redirect(r => r.MapRoute("legacy2", "foo/baz")).To(targetRoute, new { id = "123", action = "index" });

            // Map Delegate
            routes.MapDelegate("map-delegate", "this-is-a-test", rc => rc.HttpContext.Response.Write("Yeah, it's a test"));
            routes.MapDelegate("map-delegate-incoming-only", "this-is-a-test", new { whatever = new IncomingOnlyRouteConstraint() }, rc => rc.HttpContext.Response.Write("Yeah, it's a test"));

            // Map HTTP Handlers
            routes.MapHttpHandler<HelloWorldHttpHandler>("hello-world", "handlers/helloworld");
            routes.MapHttpHandler("hello-world2", "handlers/helloworld2", new HelloWorldHttpHandler());

            RouteCollection someRoutes = new RouteCollection();
            someRoutes.MapHttpHandler<HelloWorldHttpHandler>("hello-world3", "handlers/helloworld3");
            someRoutes.MapHttpHandler("hello-world4", "handlers/helloworld4", new HelloWorldHttpHandler());
            var groupRoute = new GroupRoute("~/section", someRoutes);
            routes.Add("group", groupRoute);

            var mvcRoutes = new RouteCollection();
            mvcRoutes.Map("foo1", "foo/{controller}", new { action = "index" });
            mvcRoutes.Map("foo2", "foo2/{controller}", new { action = "index" });
            routes.Add("group2", new GroupRoute("~/group2sec", mvcRoutes));

            var defaultRoute = routes.Map(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            ).SetRouteName("Default");
        }
Exemplo n.º 17
0
        protected void RegisterRoutes(RouteCollection routes)
        {
            routes.MapPageRoute("Bootstrap",
                "Bootstrap",
                "~/Bootstrap.aspx");

            routes.MapPageRoute("Html5",
                "Html5",
                "~/Html5.aspx");

            routes.MapPageRoute("jQuery",
                "jQuery",
                "~/jQuery.aspx");

            routes.MapPageRoute("Submit",
                "Submit",
                "~/Submit.aspx");

            routes.Add(new Route("Data/GetServerTime", new GetSeverTimeRouteHandler()));
            routes.Add(new Route("Data/LongRunningProcess", new LongRunningProcessRouteHandler()));

            routes.MapPageRoute("Default",
                "",
                "~/Default.aspx");
        }
Exemplo n.º 18
0
        /// <summary>
        /// Registers the routes for eServices application
        /// This is called from initialization point - Global.asax
        /// </summary>
        /// <param name="routes">The routes collection.</param>
        public static void RegisterRoutes(RouteCollection routes)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Allows to use Attribute Routes
            routes.MapMvcAttributeRoutes();

            routes.Add(
                "LocaleRoute",
                new Route(
                    "{lang}/{controller}/{action}/{id}",
                    new RouteValueDictionary(new { controller = "Home", action = "Index", area = string.Empty, id = UrlParameter.Optional, lang = UrlParameter.Optional }),
                    new RouteValueDictionary { { "lang", @"^[A-Za-z]{2}(-[A-Za-z]{2})*$" } },
                    new HyphenatedRouteHandler()));

            routes.Add(
                "Default",
                new Route(
                    "{controller}/{action}/{id}",
                    new RouteValueDictionary(new { controller = "Home", action = "Index", area = string.Empty, id = UrlParameter.Optional }),
                    new HyphenatedRouteHandler()));
        }
Exemplo n.º 19
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Joke-URL",
            //    url: "Joke/{id}/{title}",
            //    defaults: new { action = "Joke", controller = "Home" }, namespaces: new string[] { "BaseProject.Controllers" }
            //    );

            //routes.MapRoute(
            //   name: "Default",
            //   url: "{controller}/{action}/{id}",
            //   defaults: new { action = "Index", controller = "Home", id = UrlParameter.Optional }, namespaces: new string[] { "BaseProject.Controllers" }
            //   );
            const string defautlRouteUrl = "{controller}/{action}/{id}";

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            RouteValueDictionary defaultRouteValueDictionary = new RouteValueDictionary(new
            {
                controller = "Home",
                action = "Index",
                id = UrlParameter.Optional
            });
            routes.Add("DefaultGlobalised", new GlobalisedRoute(defautlRouteUrl, defaultRouteValueDictionary));
            routes.Add("Default", new Route(defautlRouteUrl, defaultRouteValueDictionary, new MvcRouteHandler()));
        }
Exemplo n.º 20
0
        internal static HtmlHelper<object> GetHtmlHelper(RouteValueDictionary routeValues)
        {
            HttpContextBase httpcontext = GetHttpContext();
            var rt = new RouteCollection();
            var defaultRoute = rt.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
            rt.Add("namedroute", new Route("named/{controller}/{action}/{id}", null) { Defaults = new RouteValueDictionary(new { id = "defaultid" }) });
            rt.Add("constraintroute", new Route("{controller}/{action}/{id}", new RouteValueDictionary(new {id = UrlParameter.Optional }),new RouteValueDictionary(new{id="\\d*"}), null));
            var rd = new RouteData {Route = defaultRoute};
            rd.Values.Add("controller", "mvcpager");
            rd.Values.Add("action", "test");
            rd.Values.Add("id", 2);
            if (routeValues != null && routeValues.Count > 0)
            {
                foreach (var de in routeValues)
                {
                    rd.Values[de.Key] = de.Value;
                }
            }
            var vdd =new ViewDataDictionary();
            var viewContext = new ViewContext()
            {
                HttpContext = httpcontext,
                RouteData = rd,
                ViewData = vdd
            };
            var mockVdc = new Mock<IViewDataContainer>();
            mockVdc.Setup(vdc => vdc.ViewData).Returns(vdd);

            var htmlHelper = new HtmlHelper<object>(viewContext, mockVdc.Object, rt);
            return htmlHelper;
        }
Exemplo n.º 21
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            //generic URLs
            routes.Add("CommonPathRoute",
                            new CommonPathRoute(
                                        "{generic_se_name}",
                                        new RouteValueDictionary(new { controller = "Home", action = "Index" }))
                                        );

            routes.Add("CommonPathRoute1",
                new CommonPathRoute(
                            "{generic_se_name}/{se_name}",
                            new RouteValueDictionary(new { controller = "Home", action = "Index" }))
                            );

            routes.Add("CommonPathRoute2",
               new CommonPathRoute(
                           "{generic_se_name}/{se_name}/{se_namelocation}",
                           new RouteValueDictionary(new { controller = "Home", action = "Index" }))
                           );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                name: "Onlinebooking",
                url: "{controller}/{action}/{ObType}/{id}/{price}",
                defaults: new { controller = "Home", action = "Index", ObType = UrlParameter.Optional, id = UrlParameter.Optional, price = UrlParameter.Optional }
            );
        }
Exemplo n.º 22
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));
            routes.Add(new Route("favicon.ico", new StopRoutingHandler()));

            routes.Add(new MountingPoint<TinyUrl>("/", () => new TinyUrl(new Urls())));
        }
Exemplo n.º 23
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.LowercaseUrls = true;
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add(new LowercaseRoute(
                url: "Assets/{action}/{id}",
                defaults: new RouteValueDictionary(new { controller = "Assets", action = "Index", id = UrlParameter.Optional }),
                routeHandler: new MvcRouteHandler()));
            routes.Add(new LowercaseRoute(
                url: "File/{id}/{type}/{hash}",
                defaults: new RouteValueDictionary(new { controller = "File", action = "Index" }),
                routeHandler:new MvcRouteHandler()));
            routes.Add(new Route(
                url: "r/e",
                defaults: new RouteValueDictionary(new { controller = "Redirect", action = "External" }),
                routeHandler:new MvcRouteHandler()));
            routes.Add(new Route(
                url: "r/i",
                defaults: new RouteValueDictionary(new { controller = "Redirect", action = "Internal" }),
                routeHandler:new MvcRouteHandler()));
            var valuesConstraint = new ExpectedValuesConstraint(LanguageTypeHelper.Instance.GetIsoNames());
            routes.Add(new LowercaseRoute(
                url: "{language}/{controller}/{action}/{id}",
                defaults: new RouteValueDictionary(new { controller = "Home", action = "Index", id = UrlParameter.Optional }),
                routeHandler: new MvcRouteHandler(),
                constraints: new RouteValueDictionary(new { language = valuesConstraint })));
            routes.MapRoute(
                name: "NoLanguage",
                url: "{any1}/{any2}/{any3}/{any4}",
                defaults: new { controller = "home", action = "detectlanguage", any1 = UrlParameter.Optional, any2 = UrlParameter.Optional, any3 = UrlParameter.Optional, any4 = UrlParameter.Optional, }
            );
        }
Exemplo n.º 24
0
 public void RegisterRoutes(RouteCollection routes)
 {
     //routes.MapBlogRoute("EyePatchBlogPost", "{controller}/{action}");
     routes.Add("EyePatchBlogPost", new PostRoute("{slug}", new MvcRouteHandler()));
     routes.Add("PostsTagged", new TaggedRoute("tagged/{tag}", new MvcRouteHandler()));
     //routes.MapRoute("PostsTagged", "tagged/{tag}", new { controller = "Blog", action = "List" });
     routes.MapRoute("BlogRssFeed", "rss", new {controller = "Blog", action = "Feed"});
 }
Exemplo n.º 25
0
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
     var templateRoute = TemplateRouteFactory.CreateRoute("css/{cssname}.css", ContentType.Css, "~/Content", FileTypeHandlingMode.WithCsExtensionPrefix);
     routes.Add("CssRoute", templateRoute);
     routes.Add("JsRoute", TemplateRouteFactory.CreateRoute("javascript/{jsname}.js", ContentType.Js, "~/Scripts", FileTypeHandlingMode.TransformFromCshtml));
     routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
 }
Exemplo n.º 26
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.Add("JsActionRoute", JsAction.JsActionRouteHandlerInstance.JsActionRoute);
            routes.Add("JsActionWebApiRoute", JsAction.JsActionWebApiRouteHandlerInstance.JsActionWebApiRoute);

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapHttpRoute(name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
            routes.MapRoute("Default","{controller}/{action}/{id}",new { controller = "Home", action = "Index", id = UrlParameter.Optional });
        }
Exemplo n.º 27
0
        public static void RegisterRoutes(RouteCollection routes) {
            // Example of adding metadata attributes programmatically
            InMemoryMetadataManager.AddColumnAttributes<Product>(p => p.UnitsInStock,
                new RangeAttribute(0, 1000) { ErrorMessage = "This field must be between {1} and {2} [from InMemoryMetadataManager]." }
                );

            DefaultModel.RegisterContext(typeof(NorthwindDataContext), new ContextConfiguration() {
                ScaffoldAllTables = true,
                MetadataProviderFactory = (type => new InMemoryMetadataTypeDescriptionProvider(type, new AssociatedMetadataTypeTypeDescriptionProvider(type)))
            });

            // Create a special escape route for handling resource requests. The this route will be evaluated
            // for all requests but the contraint will only match requests with WebResource.axd on the end.
            // The StopRoutingHandler will instruct the routing system to stop processing this request and pass
            // it on to standard ASP.NET processing.
            routes.Add(new Route("{*resource}", new StopRoutingHandler()) {
                Constraints = new RouteValueDictionary(new  { resource = @".*WebResource\.axd" })
            });

            // Create a single route override for the Edit action on the Products table
            routes.Add(new DynamicDataRoute("MyProductsEditPage/{ProductID}") {
                Constraints = new RouteValueDictionary(new { ProductID = "[1-9][0-9]*" }), // use constraints to limit which requests get matched
                Model = DefaultModel,
                Table = "Products",
                Action = PageAction.Edit,
            });

            // Use a route to provide pretty URLs, instead of having the Primary Key in the query string
            routes.Add(new PrettyDynamicDataRoute("{table}/{action}/{PK1}/{PK2}") {
                Model = DefaultModel,
                Constraints = new RouteValueDictionary(new { action = "List|Details|Insert|Edit" }),
                Defaults = new RouteValueDictionary(new { action = PageAction.List, PK1 = "", PK2 = "" })
            });

            // The following statement supports separate-page mode, where the List, Detail, Insert, and 
            // Update tasks are performed by using separate pages. To enable this mode, uncomment the following 
            // route definition, and comment out the route definitions in the combined-page mode section that follows.
            //routes.Add(new DynamicDataRoute("{table}/{action}.aspx") {
            //    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
            //    Model = DefaultModel
            //});

            // The following statements support combined-page mode, where the List, Detail, Insert, and
            // Update tasks are performed by using the same page. To enable this mode, uncomment the
            // following routes and comment out the route definition in the separate-page mode section above.
            //routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
            //    Action = PageAction.List,
            //    ViewName = "ListDetails",
            //    Model = DefaultModel
            //});

            //routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
            //    Action = PageAction.Details,
            //    ViewName = "ListDetails",
            //    Model = DefaultModel
            //});
        }
Exemplo n.º 28
0
        private static void RegisterRoutes(RouteCollection routeCollection)
        {
            Route previewRoute = new Route(PreviewRouteHandler.URL, new PreviewRouteHandler());
            routeCollection.Add(PreviewRouteHandler.ROUTE_NAME, previewRoute);

            Route cultureRoute = new Route(SelectCultureRouteHandler.URL, new SelectCultureRouteHandler());
            cultureRoute.Constraints = new RouteValueDictionary { { SelectCultureRouteHandler.ROUTE_VALUE_CULTURE, SelectCultureRouteHandler.CultureRegex } };
            routeCollection.Add(SelectCultureRouteHandler.ROUTE_NAME, cultureRoute);
        }
Exemplo n.º 29
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("Uploads/{*pathInfo}");
            routes.IgnoreRoute("Content/{*pathInfo}");
            routes.IgnoreRoute("Scripts/{*pathInfo}");
            routes.IgnoreRoute("ckfinder/userfiles/images/{*pathInfo}");
            routes.IgnoreRoute("ImageHandler.ashx");
            routes.IgnoreRoute("robots.txt");

            AreaRegistration.RegisterAllAreas();

            routes.Add("ApiRouteFormat", new DomainRoute(
                "api." + DomainName,
                "{account}/{action}/{moduleid}/{id}.{format}",
                new { controller = "Api", action = "module", account = "",  moduleid = "", format = "xml", id = UrlParameter.Optional }
            ));

            routes.Add("ApiRoute", new DomainRoute(
                "api." + DomainName,
                "{account}/{action}/{moduleid}.{format}",
                new { controller = "Api", action = "module", account = "", moduleid = "", format = "xml" }
            ));

            routes.Add("HelpRoute", new DomainRoute(
                "help." + DomainName,
                "{action}",
                new { controller = "Help", action = "Index" }
            ));

            routes.MapRoute("Let_me_know", "let_me_know", new { controller = "Home", action = "Let_me_know" });
            routes.MapRoute("New_home", "New_home", new { controller = "Home", action = "New_home" });
            routes.MapRoute("OpenId", "OpenId", new { controller = "Account", action = "OpenId" });
            routes.MapRoute("Signup", "Signup", new { controller = "Account", action = "Signup" });

            routes.MapRoute(
                "Dynamic_modules_query",
                "dyn/{moduleid}/{modulename}/Query{format}/{id}",
                new { controller = "DynamicModule", modulename = "", moduleid = "", action = "Query", format = ".xml", id = UrlParameter.Optional }
            );

            routes.Add(
                "Dynamic_modules_route", new DomainRoute(
                "{account}." + DomainName,
                "dyn/{moduleid}/{modulename}/{action}/{id}",
                new { moduleid = "", modulename = "", controller = "DynamicModule", action = "List", id = UrlParameter.Optional }
            ));

            routes.Add(
                "Default", new DomainRoute(
                "{account}." + DomainName,
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", account = UrlParameter.Optional, id = UrlParameter.Optional }
            ));

            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
        }
Exemplo n.º 30
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            //routes.RouteExistingFiles = true;

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);

            //routes.MapRoute("AddControllersRoute", "Home/{action}/{id}/{*catchall}",
            //    new
            //    {
            //        controller = "Home",
            //        action = "Index",
            //        id = UrlParameter.Optional
            //    },
            //    new[] { "UrlsAndRoutes.AdditionalControllers" });

            //Route myRoute = routes.MapRoute("MyRoute", "{controller}/{Action}/{id}/{*catchall}",
            //    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            //    new {
            //            customConstraint = new UserAgentConstraint("Chrome")
            //        },
            //    new[] { "UrlsAndRoutes.AdditionalControllers" });

            //myRoute.DataTokens["UseNamespaceFallback"] = false;

            ////routes.MapRoute("DiskFile", "Content/StaticContent.html",
            ////    new { controller = "Customer", action = "List" });

            ////routes.MapRoute("ChromeRoute", "{*catchall}",
            ////    new { controller = "Home", action = "Index" },
            ////    new { customConstraint = new UserAgentConstraint("Chrome") },
            ////    new[] { "UrlsAndRoutes.AdditionalControllers" });

            ////routes.MapRoute("MyRoute", "{controller}/{action}/{id}/{*catchall}",
            ////    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            ////    new[] { "UrlsAndRoutes.Controllers" });

            //routes.MapRoute("NewRoute", "App/Do{action}",
            //    new { controller = "Home" });

            //routes.MapRoute("MyRoute", "{controller}/{action}/{id}",
            //    new { controller="Home", action="Index", id=UrlParameter.Optional});

            routes.Add(new Route("SayHello", new CustomRouteHandler()));

            routes.Add(new LegacyRoute(
                "~/articles/Windows_3.1_Overview.html",
                "~/old/.Net_1.0_Class_Library"));

            routes.MapRoute("MyRoute", "{controller}/{action}");
            routes.MapRoute("MyOtherRoute", "App/{action}", new { controller = "Home" });
        }
Exemplo n.º 31
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute(
                RouteName.Home,
                "",
                MVC.Pages.Home());

            routes.MapRoute(
                RouteName.StatisticsHome,
                "stats",
                new { controller = MVC.Statistics.Name, action = "Index" });

            routes.MapRoute(
                RouteName.Stats,
                "stats/totals",
                MVC.Statistics.Totals());

            routes.MapRoute(
                RouteName.StatisticsPackages,
                "stats/packages",
                new { controller = MVC.Statistics.Name, action = "Packages" });

            routes.MapRoute(
                RouteName.StatisticsPackageVersions,
                "stats/packageversions",
                new { controller = MVC.Statistics.Name, action = "PackageVersions" });

            routes.MapRoute(
                RouteName.StatisticsPackageDownloadsDetail,
                "stats/packages/{id}/{version}",
                new { controller = MVC.Statistics.Name, action = "PackageDownloadsDetail" });

            routes.MapRoute(
                RouteName.StatisticsPackageDownloadsByVersion,
                "stats/packages/{id}",
                new { controller = MVC.Statistics.Name, action = "PackageDownloadsByVersion" });

            routes.Add(new JsonRoute("json/{controller}"));

            routes.MapRoute(
                RouteName.Policies,
                "policies/{action}",
                MVC.Pages.Terms());

            var packageListRoute = routes.MapRoute(
                RouteName.ListPackages,
                "packages",
                MVC.Packages.ListPackages());

            var uploadPackageRoute = routes.MapRoute(
                RouteName.UploadPackage,
                "packages/upload",
                new { controller = MVC.Packages.Name, action = "UploadPackage" });

            routes.MapRoute(
                RouteName.UploadPackageProgress,
                "packages/upload-progress",
                MVC.Packages.UploadPackageProgress());

            routes.MapRoute(
                RouteName.VerifyPackage,
                "packages/verify-upload",
                new { controller = MVC.Packages.Name, action = "VerifyPackage" });

            routes.MapRoute(
                RouteName.CancelUpload,
                "packages/cancel-upload",
                new { controller = MVC.Packages.Name, action = "CancelUpload" });

            routes.MapRoute(
                RouteName.PackageOwnerConfirmation,
                "packages/{id}/owners/{username}/confirm/{token}",
                new { controller = MVC.Packages.Name, action = "ConfirmOwner" });

            // We need the following two routes (rather than just one) due to Routing's
            // Consecutive Optional Parameter bug. :(
            var packageDisplayRoute = routes.MapRoute(
                RouteName.DisplayPackage,
                "packages/{id}/{version}",
                MVC.Packages.DisplayPackage().AddRouteValue("version", UrlParameter.Optional),
                null /*defaults*/,
                new { version = new VersionRouteConstraint() });

            var packageVersionActionRoute = routes.MapRoute(
                RouteName.PackageVersionAction,
                "packages/{id}/{version}/{action}",
                new { controller = MVC.Packages.Name },
                new { version = new VersionRouteConstraint() });

            var packageActionRoute = routes.MapRoute(
                RouteName.PackageAction,
                "packages/{id}/{action}",
                new { controller = MVC.Packages.Name });

            var resendRoute = routes.MapRoute(
                "ResendConfirmation",
                "account/ResendConfirmation",
                MVC.Users.ResendConfirmation());

            //Redirecting v1 Confirmation Route
            routes.Redirect(
                r => r.MapRoute(
                    "v1Confirmation",
                    "Users/Account/ChallengeEmail")).To(resendRoute);

            routes.MapRoute(
                RouteName.Authentication,
                "users/account/{action}",
                new { controller = MVC.Authentication.Name });

            routes.MapRoute(
                RouteName.Profile,
                "profiles/{username}",
                MVC.Users.Profiles());

            routes.MapRoute(
                RouteName.PasswordReset,
                "account/{action}/{username}/{token}",
                MVC.Users.ResetPassword());

            routes.MapRoute(
                RouteName.Account,
                "account/{action}",
                MVC.Users.Account());

            routes.MapRoute(
                RouteName.CuratedFeed,
                "curated-feeds/{name}",
                new { controller = CuratedFeedsController.ControllerName, action = "CuratedFeed" });

            routes.MapRoute(
                RouteName.CuratedFeedListPackages,
                "curated-feeds/{curatedFeedName}/packages",
                MVC.CuratedFeeds.ListPackages());

            routes.MapRoute(
                RouteName.CreateCuratedPackageForm,
                "forms/add-package-to-curated-feed",
                new { controller = CuratedPackagesController.ControllerName, action = "CreateCuratedPackageForm" });

            routes.MapRoute(
                RouteName.CuratedPackage,
                "curated-feeds/{curatedFeedName}/curated-packages/{curatedPackageId}",
                new { controller = CuratedPackagesController.ControllerName, action = "CuratedPackage" });

            routes.MapRoute(
                RouteName.CuratedPackages,
                "curated-feeds/{curatedFeedName}/curated-packages",
                new { controller = CuratedPackagesController.ControllerName, action = "CuratedPackages" });

            // TODO : Most of the routes are essentially of the format api/v{x}/*. We should refactor the code to vary them by the version.
            // V1 Routes
            // If the push url is /api/v1 then NuGet.Core would ping the path to resolve redirection.
            routes.MapRoute(
                "v1" + RouteName.VerifyPackageKey,
                "api/v1/verifykey/{id}/{version}",
                MVC.Api.VerifyPackageKey(),
                defaults: new { id = UrlParameter.Optional, version = UrlParameter.Optional });

            var downloadRoute = routes.MapRoute(
                "v1" + RouteName.DownloadPackage,
                "api/v1/package/{id}/{version}",
                defaults: new { controller = MVC.Api.Name, action = "GetPackageApi", version = UrlParameter.Optional },
                constraints: new { httpMethod = new HttpMethodConstraint("GET") });

            routes.MapRoute(
                "v1" + RouteName.PushPackageApi,
                "v1/PackageFiles/{apiKey}/nupkg",
                defaults: new { controller = MVC.Api.Name, action = "PushPackageApi" },
                constraints: new { httpMethod = new HttpMethodConstraint("POST") });

            routes.MapRoute(
                "v1" + RouteName.DeletePackageApi,
                "v1/Packages/{apiKey}/{id}/{version}",
                MVC.Api.DeletePackage());

            routes.MapRoute(
                "v1" + RouteName.PublishPackageApi,
                "v1/PublishedPackages/Publish",
                MVC.Api.PublishPackage());

            // V2 routes
            routes.MapRoute(
                "v2" + RouteName.VerifyPackageKey,
                "api/v2/verifykey/{id}/{version}",
                MVC.Api.VerifyPackageKey(),
                defaults: new { id = UrlParameter.Optional, version = UrlParameter.Optional });

            routes.MapRoute(
                "v2CuratedFeeds" + RouteName.DownloadPackage,
                "api/v2/curated-feeds/package/{id}/{version}",
                defaults: new { controller = MVC.Api.Name, action = "GetPackageApi", version = UrlParameter.Optional },
                constraints: new { httpMethod = new HttpMethodConstraint("GET") });

            routes.MapRoute(
                "v2" + RouteName.DownloadPackage,
                "api/v2/package/{id}/{version}",
                defaults: new { controller = MVC.Api.Name, action = "GetPackageApi", version = UrlParameter.Optional },
                constraints: new { httpMethod = new HttpMethodConstraint("GET") });

            routes.MapRoute(
                "v2" + RouteName.PushPackageApi,
                "api/v2/package",
                defaults: new { controller = MVC.Api.Name, action = "PushPackageApi" },
                constraints: new { httpMethod = new HttpMethodConstraint("PUT") });

            routes.MapRoute(
                "v2" + RouteName.DeletePackageApi,
                "api/v2/package/{id}/{version}",
                MVC.Api.DeletePackage(),
                defaults: null,
                constraints: new { httpMethod = new HttpMethodConstraint("DELETE") });

            routes.MapRoute(
                "v2" + RouteName.PublishPackageApi,
                "api/v2/package/{id}/{version}",
                MVC.Api.PublishPackage(),
                defaults: null,
                constraints: new { httpMethod = new HttpMethodConstraint("POST") });

            routes.MapRoute(
                "v2PackageIds",
                "api/v2/package-ids",
                MVC.Api.GetPackageIds());

            routes.MapRoute(
                "v2PackageVersions",
                "api/v2/package-versions/{id}",
                MVC.Api.GetPackageVersions());

            routes.MapRoute(
                RouteName.StatisticsDownloadsApi,
                "api/v2/stats/downloads/last6weeks",
                defaults: new { controller = MVC.Api.Name, action = "StatisticsDownloadsApi" },
                constraints: new { httpMethod = new HttpMethodConstraint("GET") });

            routes.MapRoute(
                RouteName.DownloadNuGetExe,
                "nuget.exe",
                new { controller = MVC.Api.Name, action = "GetNuGetExeApi" });

            // Redirected Legacy Routes

            routes.Redirect(
                r => r.MapRoute(
                    "ReportAbuse",
                    "Package/ReportAbuse/{id}/{version}",
                    MVC.Packages.ReportAbuse()),
                permanent: true).To(packageVersionActionRoute);

            routes.Redirect(
                r => r.MapRoute(
                    "PackageActions",
                    "Package/{action}/{id}",
                    MVC.Packages.ContactOwners(),
                    null /*defaults*/,
                    // This next bit looks bad, but it's not. It will never change because
                    // it's mapping the legacy routes to the new better routes.
                    new { action = "ContactOwners|ManagePackageOwners" }),
                permanent: true).To(packageActionRoute);


            // TODO: this route looks broken as there is no EditPackage action
            //routes.Redirect(
            //    r => r.MapRoute(
            //        "EditPackage",
            //        "Package/Edit/{id}/{version}",
            //        new { controller = PackagesController.ControllerName, action = "EditPackage" }),
            //    permanent: true).To(packageVersionActionRoute);

            routes.Redirect(
                r => r.MapRoute(
                    RouteName.ListPackages,
                    "List/Packages",
                    MVC.Packages.ListPackages()),
                permanent: true).To(packageListRoute);

            routes.Redirect(
                r => r.MapRoute(
                    RouteName.DisplayPackage,
                    "List/Packages/{id}/{version}",
                    MVC.Packages.DisplayPackage().AddRouteValue("version", UrlParameter.Optional)),
                permanent: true).To(packageDisplayRoute);

            routes.Redirect(
                r => r.MapRoute(
                    RouteName.NewSubmission,
                    "Contribute/NewSubmission",
                    new { controller = MVC.Packages.Name, action = "UploadPackage" }),
                permanent: true).To(uploadPackageRoute);

            routes.Redirect(
                r => r.MapRoute(
                    "LegacyDownloadRoute",
                    "v1/Package/Download/{id}/{version}",
                    new { controller = MVC.Api.Name, action = "GetPackageApi", version = UrlParameter.Optional }),
                permanent: true).To(downloadRoute);
        }
Exemplo n.º 32
0
        public static void RegisterProtocols(HttpConfiguration httpConfiguration, RouteCollection routes, IConfigurationRepository configuration, IUserRepository users, IRelyingPartyRepository relyingParties)
        {
            // require SSL for all web api endpoints
            httpConfiguration.MessageHandlers.Add(new RequireHttpsHandler());

            #region Protocols
            // federation metadata
            if (configuration.FederationMetadata.Enabled)
            {
                routes.MapRoute(
                    "FederationMetadata",
                    Thinktecture.IdentityServer.Endpoints.Paths.WSFedMetadata,
                    new { controller = "FederationMetadata", action = "Generate" }
                    );
            }

            // ws-federation
            if (configuration.WSFederation.Enabled && configuration.WSFederation.EnableAuthentication)
            {
                routes.MapRoute(
                    "wsfederation",
                    Thinktecture.IdentityServer.Endpoints.Paths.WSFedIssuePage,
                    new { controller = "WSFederation", action = "issue" }
                    );
            }

            // ws-federation HRD
            if (configuration.WSFederation.Enabled && configuration.WSFederation.EnableFederation)
            {
                routes.MapRoute(
                    "hrd",
                    Thinktecture.IdentityServer.Endpoints.Paths.WSFedHRD,
                    new { controller = "Hrd", action = "issue" }
                    );
                routes.MapRoute(
                    "hrd-select",
                    Thinktecture.IdentityServer.Endpoints.Paths.WSFedHRDSelect,
                    new { controller = "Hrd", action = "Select" },
                    new { method = new HttpMethodConstraint("POST") }
                    );

                // callback endpoint
                OAuth2Client.OAuthCallbackUrl = Thinktecture.IdentityServer.Endpoints.Paths.OAuth2Callback;
                routes.MapRoute(
                    "oauth2callback",
                    Thinktecture.IdentityServer.Endpoints.Paths.OAuth2Callback,
                    new { controller = "Hrd", action = "OAuthTokenCallback" }
                    );
            }

            // oauth2 endpoint
            if (configuration.OAuth2.Enabled)
            {
                // authorize endpoint
                routes.MapRoute(
                    "oauth2authorize",
                    Endpoints.Paths.OAuth2Authorize,
                    new { controller = "OAuth2Authorize", action = "index" }
                    );

                // token endpoint
                routes.MapHttpRoute(
                    name: "oauth2token",
                    routeTemplate: Endpoints.Paths.OAuth2Token,
                    defaults: new { controller = "OAuth2Token" },
                    constraints: null,
                    handler: new AuthenticationHandler(CreateClientAuthConfig(), httpConfiguration)
                    );
            }

            // open id connect
            if (configuration.OpenIdConnect.Enabled &&
                configuration.Keys.SigningCertificate != null)
            {
                // authorize endpoint
                routes.MapRoute(
                    "oidcauthorize",
                    Endpoints.Paths.OidcAuthorize,
                    new { controller = "OidcAuthorize", action = "index" }
                    );

                // token endpoint
                routes.MapHttpRoute(
                    name: "oidctoken",
                    routeTemplate: Endpoints.Paths.OidcToken,
                    defaults: new { controller = "OidcToken" },
                    constraints: null,
                    handler: new AuthenticationHandler(CreateClientAuthConfig(), httpConfiguration)
                    );

                // userinfo endpoint
                routes.MapHttpRoute(
                    name: "oidcuserinfo",
                    routeTemplate: Endpoints.Paths.OidcUserInfo,
                    defaults: new { controller = "OidcUserInfo" },
                    constraints: null,
                    handler: new AuthenticationHandler(CreateUserInfoAuthConfig(configuration), httpConfiguration)
                    );
            }

            // adfs integration
            if (configuration.AdfsIntegration.Enabled)
            {
                routes.MapHttpRoute(
                    name: "adfs",
                    routeTemplate: Thinktecture.IdentityServer.Endpoints.Paths.AdfsIntegration,
                    defaults: new { controller = "Adfs" }
                    );
            }

            // simple http endpoint
            if (configuration.SimpleHttp.Enabled)
            {
                routes.MapHttpRoute(
                    name: "simplehttp",
                    routeTemplate: Thinktecture.IdentityServer.Endpoints.Paths.SimpleHttp,
                    defaults: new { controller = "SimpleHttp" },
                    constraints: null,
                    handler: new AuthenticationHandler(CreateBasicAuthConfig(users), httpConfiguration)
                    );
            }

            // ws-trust
            if (configuration.WSTrust.Enabled)
            {
                routes.Add(new ServiceRoute(
                               Thinktecture.IdentityServer.Endpoints.Paths.WSTrustBase,
                               new TokenServiceHostFactory(),
                               typeof(TokenServiceConfiguration))
                           );
            }
            #endregion
        }
Exemplo n.º 33
0
        private static void RegisterRoutes(RouteCollection routes)
        {
            #region "Getting SageFrame Page Extension"

            string ext = SageFrameSettingKeys.PageExtension;
            if (string.IsNullOrEmpty(ext))
            {
                ext = ".htm";
            }

            #endregion

            #region "SageFrame Ignore Routing"

            routes.RouteExistingFiles = false;
            routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));
            routes.Ignore("{*alljs}", new { alljs = @".*\.(js|asmx|jpg|png|jpeg|css)(/.*)?" });
            routes.Ignore("install", new { installwizard = "Install/InstallWizard.aspx" });
            routes.Add(new Route("Modules/{*pathInfo}", new StopRoutingHandler()));

            #endregion

            #region "SageFrame Core Routing"

            routes.Add("sfPortalfa", new System.Web.Routing.Route("Admin/Admin/Portal.aspx" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfrouting2", new System.Web.Routing.Route("sf/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Admin.aspx")));
            //routes.Add("sfrouting3", new System.Web.Routing.Route("sf/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Admin.aspx")));
            //routes.Add("sfrouting4", new System.Web.Routing.Route("sf/sf/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Admin.aspx")));
            //routes.Add("sfrouting5", new System.Web.Routing.Route("portal/{PortalSEOName}/sf/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Admin.aspx")));
            //routes.Add("sfrouting6", new System.Web.Routing.Route("portal/{PortalSEOName}/sf/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Admin.aspx")));
            //routes.Add("SageFrameRoutingCategory", new Route("category/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingProductDetail", new Route("item/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingTagsAll", new Route("tags/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingBrand", new Route("brand/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingService", new Route("service/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingTagsItems", new Route("tagsitems/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingSearchTerm", new Route("search/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingShoppingOption", new Route("option/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRoutingCouponsAll", new Route("coupons/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRouting0", new Route("portal/{PortalSEOName}/category/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRouting01", new Route("portal/{PortalSEOName}/item/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRouting02", new Route("portal/{PortalSEOName}/tags/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRouting03", new Route("portal/{PortalSEOName}/tagsitems/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRouting04", new Route("portal/{PortalSEOName}/search/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("SageFrameRouting05", new Route("portal/{PortalSEOName}/option/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            #endregion

            #region "AspxCommerce Routing"

            //routes.Add("sfAspx1", new System.Web.Routing.Route("Admin/AspxCommerce/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx2", new System.Web.Routing.Route("admin/AspxCommerce/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx3", new System.Web.Routing.Route("Admin/Admin/AspxCommerce/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx4", new System.Web.Routing.Route("admin/admin/AspxCommerce/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx5", new System.Web.Routing.Route("Admin/AspxCommerce/{parentname}/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx6", new System.Web.Routing.Route("admin/AspxCommerce/{parentname}/{pagepath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx7", new System.Web.Routing.Route("Admin/AspxCommerce/{parentname}/{subparent}/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx8", new System.Web.Routing.Route("admin/AspxCommerce/{parentname}/{subparent}/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx9", new System.Web.Routing.Route("Admin/AspxCommerce/{parentname}/{subparent}/{subsubparent}/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("sfAspx10", new System.Web.Routing.Route("admin/AspxCommerce/{parentname}/{subparent}/{subsubparent}/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));

            #endregion

            #region "Routes To ManagePage"

            //  routes to managepage
            routes.Add("SageFrameRouting1", new Route("portal/{PortalSEOName}/{UserModuleID}/Sagin/{ControlType}/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/ManagePage.aspx")));
            routes.Add("SageFrameRouting2", new Route("{UserModuleID}/Sagin/{ControlType}/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/ManagePage.aspx")));
            routes.Add("controlrouting1", new Route("sagin/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/HandleModuleControls.aspx")));
            routes.Add("controlrouting2", new Route("sagin/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/HandleModuleControls.aspx")));
            routes.Add("controlrouting3", new Route("sagin/{PagePath}.aspx" + "/{*Param}", new SageFrameRouteHandler("~/Sagin/HandleModuleControls.aspx")));

            #endregion

            #region "Portal Routing"

            //Portal routing
            routes.Add("sfPortal1", new System.Web.Routing.Route("portal/{PortalSEOName}/Admin/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal2", new System.Web.Routing.Route("portal/{PortalSEOName}/Admin/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal3", new System.Web.Routing.Route("portal/{PortalSEOName}/Admin/Admin/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal4", new System.Web.Routing.Route("portal/{PortalSEOName}/Admin/Admin/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal5", new System.Web.Routing.Route("portal/{PortalSEOName}/Super-User/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal6", new System.Web.Routing.Route("portal/{PortalSEOName}/Super-User/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal7", new System.Web.Routing.Route("Admin/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal8", new System.Web.Routing.Route("Admin/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal9", new System.Web.Routing.Route("Admin/Admin/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal10", new System.Web.Routing.Route("admin/admin/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal11", new System.Web.Routing.Route("portal/{PortalSEOName}/admin/admin/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal12", new System.Web.Routing.Route("portal/{PortalSEOName}/admin/admin/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal13", new System.Web.Routing.Route("portal/{PortalSEOName}/admin/Super-User/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal14", new System.Web.Routing.Route("portal/{PortalSEOName}/admin/Super-User/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal15", new System.Web.Routing.Route("admin/super-user/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal16", new System.Web.Routing.Route("admin/super-user/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal17", new System.Web.Routing.Route("Admin" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal18", new System.Web.Routing.Route("Admin" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal19", new System.Web.Routing.Route("Super-User" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal20", new System.Web.Routing.Route("Super-User" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal21", new System.Web.Routing.Route("Super-User/{PagePath}" + ext, new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal22", new System.Web.Routing.Route("Super-User/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("sfPortal23", new System.Web.Routing.Route("portal/{PortalSEOName}/{PagePath}" + ext, new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sfPortal24", new System.Web.Routing.Route("portal/{PortalSEOName}/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            #endregion

            #region "Page Routing"

            //page routing
            routes.Add("sage10", new Route("Dashboard/{PagePath}/{*Param}", new SageFrameRouteHandler("~/Dashboard.aspx")));
            routes.Add("sage11", new Route("componentadmin/{*Param}", new SageFrameRouteHandler("~/ComponentData.aspx")));
            routes.Add("webbuilderparam", new Route("Webbuilder/{*Param}", new SageFrameRouteHandler("~/Webbuilder.aspx")));
            routes.Add("sage", new Route("Default.aspx", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage9", new Route("SageEditor" + ext, new SageFrameRouteHandler("~/" + CommonHelper.SageEditor)));

            routes.Add("sage1", new Route("{PagePath}" + ext, new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            //routes.Add("sage1", new Route("{PagePath}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage2", new Route("{parentname}/{PagePath}" + ext, new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage3", new Route("{parentname}/{subparent}/{PagePath}" + ext, new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage4", new Route("{parentname}/{subparent}/{modulename}/{PagePath}" + ext, new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage5", new Route("{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage6", new Route("{parentname}/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage7", new Route("{parentname}/{subparent}/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("sage8", new Route("{parentname}/{subparent}/{modulename}/{PagePath}" + ext + "/{*Param}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("extraparameters", new Route("{PagePath}/{*Param}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("allroute", new Route("{*PagePath}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            #endregion
        }
Exemplo n.º 34
0
        /// <summary>
        /// Looks for any action methods in 'assemblyToSearch' that have the RouteAttribute defined,
        /// adding the routes to the parameter 'routes' collection.
        /// </summary>
        /// <param name="assemblyToSearch">An assembly containing Controllers with public methods decorated with the RouteAttribute</param>
        public static void MapDecoratedRoutes(RouteCollection routes, Assembly assemblyToSearch)
        {
            var decoratedMethods = from t in assemblyToSearch.GetTypes()
                                   where t.IsSubclassOf(typeof(System.Web.Mvc.Controller))
                                   from m in t.GetMethods()
                                   where m.IsDefined(typeof(RouteAttribute), false)
                                   select m;

            Debug.WriteLine(string.Format("MapDecoratedRoutes - found {0} methods decorated with RouteAttribute", decoratedMethods.Count()));

            var methodsToRegister = new Dictionary <RouteAttribute, MethodInfo>();

            // first, collect all the methods decorated with our RouteAttribute
            foreach (var method in decoratedMethods)
            {
                foreach (var attr in method.GetCustomAttributes(typeof(RouteAttribute), false))
                {
                    var ra = (RouteAttribute)attr;
                    if (!methodsToRegister.Any(p => p.Key.Url.Equals(ra.Url)))
                    {
                        methodsToRegister.Add(ra, method);
                    }
                    else
                    {
                        Debug.WriteLine("MapDecoratedRoutes - found duplicate url -> " + ra.Url);
                    }
                }
            }

            // to ease route debugging later (and accommodate routes with response-type-specific {format} parameters),
            // we'll sort the routes alphabetically, applying a custom comparer for urls with {format} in them
            var urls = new List <string>();

            methodsToRegister.Keys.ToList().ForEach(k => urls.Add(k.Url));

            urls.Sort((x, y) =>
            {
                // one url contains the other, but with extra parameters
                if (x.IndexOf(y) > -1 || y.IndexOf(x) > -1)
                {
                    // bubble up the format-carrying routes
                    if (x.Contains("{format}"))
                    {
                        return(-1);
                    }
                    if (y.Contains("{format}"))
                    {
                        return(1);
                    }
                }
                return(x.CompareTo(y));
            });

            // now register the unique urls to the Controller.Method that they were decorated upon, respecting the sort
            foreach (var url in urls)
            {
                var pair           = methodsToRegister.First(p => p.Key.Url == url);
                var routeAttribute = pair.Key;
                var method         = pair.Value;
                var action         = method.Name;

                var controllerType      = method.ReflectedType;
                var controllerName      = controllerType.Name.Replace("Controller", "");
                var controllerNamespace = controllerType.FullName.Replace("." + controllerType.Name, "");

                Debug.WriteLine(string.Format("MapDecoratedRoutes - mapping url '{0}' to {1}.{2}.{3}",
                                              routeAttribute.Url, controllerNamespace, controllerName, action));

                var route = new Route(routeAttribute.Url, new MvcRouteHandler());
                route.Defaults = new RouteValueDictionary(new { controller = controllerName, action = action });

                // urls with optional parameters may specify which parameters can be ignored and still match
                if (routeAttribute.Optional != null && routeAttribute.Optional.Length > 0)
                {
                    for (int i = 0; i < routeAttribute.Optional.Length; i++)
                    {
                        route.Defaults.Add(routeAttribute.Optional[i], ""); // default route parameter value should be empty string..
                    }
                }

                // fully-qualify this new route to its controller method, so that multiple assemblies can have similar
                // controller names/routes, differing only by namespace,
                // e.g. StackOverflow.Controllers.HomeController, StackOverflow.Careers.Controllers.HomeController
                route.DataTokens = new RouteValueDictionary(new { namespaces = new[] { controllerNamespace } });

                routes.Add(routeAttribute.Name, route);
            }
        }
Exemplo n.º 35
0
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.Ignore("{*tinymce}", new { tinymce = @"(.*/)?TinyMCEHandler\.ashx.*" });
     routes.Ignore("{*facebook}", new { facebook = @"(.*/)?FacebookLogin\.ashx.*" });
     routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));
     routes.Add(new Route("admin/{path}", new StopRoutingHandler()));
     routes.Add(new Route("css/{path}", new StopRoutingHandler()));
     routes.Add(new Route("img/{path}", new StopRoutingHandler()));
     routes.Add(new Route("images/{path}", new StopRoutingHandler()));
     routes.Add(new Route("tft-js/{path}", new StopRoutingHandler()));
     routes.Add(new Route("uploads/{path}", new StopRoutingHandler()));
     //Blog virtual pathing fix
     if (!String.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["BlogEngine.VirtualPath"]))
     {
         routes.Add(new Route(System.Configuration.ConfigurationManager.AppSettings["BlogEngine.VirtualPath"].Replace("~/", "") + "{*path}", new StopRoutingHandler()));
     }
     routes.Add(new Route("forum/{*path}", new StopRoutingHandler()));
     routes.MapPageRoute("HTCResources", "{resource}.htc", "~/{resource}.htc");
     routes.MapPageRoute("HomeValues", "{Microsite}/home-value", "~/home-valuation.aspx");
     routes.MapPageRoute("ShowcaseDetails", "{Microsite}/home-details", "~/showcase-item.aspx");
     routes.Add(new Route("{Microsite}/{CMPage}", new RoutingHandler()));
     routes.Add(new Route("{MicrositeOrCMPage}", new RoutingHandler()));
 }
Exemplo n.º 36
0
 /// <summary>
 /// Url地址
 /// </summary>
 /// <param name="routes"></param>
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.Add("Page", new Route("{language}/{pageName}", new UrlRoutingHandlers()));
 }
Exemplo n.º 37
0
        public static void RegisterUIRoutes(RouteCollection routes)
        {
            routes.MapRoute(
                RouteName.Home,
                "",
                new { controller = "Pages", action = "Home" }); // T4MVC doesn't work with Async Action

            routes.MapRoute(
                RouteName.Error500,
                "errors/500",
                new { controller = "Errors", action = "InternalError" });

            routes.MapRoute(
                RouteName.Error404,
                "errors/404",
                new { controller = "Errors", action = "NotFound" });

            routes.MapRoute(
                RouteName.StatisticsHome,
                "stats",
                new { controller = "Statistics", action = "Index" });

            routes.MapRoute(
                RouteName.Stats,
                "stats/totals",
                new { controller = "Statistics", action = "Totals" });

            routes.MapRoute(
                RouteName.StatisticsPackages,
                "stats/packages",
                new { controller = "Statistics", action = "Packages" });

            routes.MapRoute(
                RouteName.StatisticsPackageVersions,
                "stats/packageversions",
                new { controller = "Statistics", action = "PackageVersions" });

            routes.MapRoute(
                RouteName.StatisticsPackageDownloadsDetail,
                "stats/packages/{id}/{version}",
                new { controller = "Statistics", action = "PackageDownloadsDetail" });

            routes.MapRoute(
                RouteName.StatisticsPackageDownloadsByVersion,
                "stats/packages/{id}",
                new { controller = "Statistics", action = "PackageDownloadsByVersion" });

            routes.Add(new JsonRoute("json/{controller}"));

            routes.MapRoute(
                RouteName.Contributors,
                "pages/contributors",
                new { controller = "Pages", action = "Contributors" });

            routes.MapRoute(
                RouteName.Policies,
                "policies/{action}",
                new { controller = "Pages" });

            routes.MapRoute(
                RouteName.Pages,
                "pages/{pageName}",
                new { controller = "Pages", action = "Page" });

            var packageListRoute = routes.MapRoute(
                RouteName.ListPackages,
                "packages",
                new { controller = "Packages", action = "ListPackages" });

            var uploadPackageRoute = routes.MapRoute(
                RouteName.UploadPackage,
                "packages/upload",
                new { controller = "Packages", action = "UploadPackage" });

            routes.MapRoute(
                RouteName.UploadPackageProgress,
                "packages/upload-progress",
                new { controller = "Packages", action = "UploadPackageProgress" });

            routes.MapRoute(
                RouteName.VerifyPackage,
                "packages/verify-upload",
                new { controller = "Packages", action = "VerifyPackage" });

            routes.MapRoute(
                RouteName.CancelUpload,
                "packages/cancel-upload",
                new { controller = "Packages", action = "CancelUpload" });

            routes.MapRoute(
                RouteName.PackageOwnerConfirmation,
                "packages/{id}/owners/{username}/confirm/{token}",
                new { controller = "Packages", action = "ConfirmOwner" });

            // We need the following two routes (rather than just one) due to Routing's
            // Consecutive Optional Parameter bug. :(
            var packageDisplayRoute = routes.MapRoute(
                RouteName.DisplayPackage,
                "packages/{id}/{version}",
                new {
                controller = "packages",
                action     = "DisplayPackage",
                version    = UrlParameter.Optional
            },
                new { version = new VersionRouteConstraint() });

            routes.MapRoute(
                RouteName.PackageEnableLicenseReport,
                "packages/{id}/{version}/EnableLicenseReport",
                new { controller = "Packages", action = "SetLicenseReportVisibility", visible = true },
                new { version = new VersionRouteConstraint() });

            routes.MapRoute(
                RouteName.PackageDisableLicenseReport,
                "packages/{id}/{version}/DisableLicenseReport",
                new { controller = "Packages", action = "SetLicenseReportVisibility", visible = false },
                new { version = new VersionRouteConstraint() });

            var packageVersionActionRoute = routes.MapRoute(
                RouteName.PackageVersionAction,
                "packages/{id}/{version}/{action}",
                new { controller = "Packages" },
                new { version = new VersionRouteConstraint() });

            var packageActionRoute = routes.MapRoute(
                RouteName.PackageAction,
                "packages/{id}/{action}",
                new { controller = "Packages" });

            var confirmationRequiredRoute = routes.MapRoute(
                "ConfirmationRequired",
                "account/ConfirmationRequired",
                new { controller = "Users", action = "ConfirmationRequired" });

            //Redirecting v1 Confirmation Route
            routes.Redirect(
                r => r.MapRoute(
                    "v1Confirmation",
                    "Users/Account/ChallengeEmail")).To(confirmationRequiredRoute);

            routes.MapRoute(
                RouteName.ExternalAuthenticationCallback,
                "users/account/authenticate/return",
                new { controller = "Authentication", action = "LinkExternalAccount" });

            routes.MapRoute(
                RouteName.ExternalAuthentication,
                "users/account/authenticate/{provider}",
                new { controller = "Authentication", action = "Authenticate" });

            routes.MapRoute(
                RouteName.Authentication,
                "users/account/{action}",
                new { controller = "Authentication" });

            routes.MapRoute(
                RouteName.Profile,
                "profiles/{username}",
                new { controller = "Users", action = "Profiles" });

            routes.MapRoute(
                RouteName.LegacyRegister,
                "account/register",
                new { controller = "Authentication", action = "Register" });

            routes.MapRoute(
                RouteName.RemovePassword,
                "account/RemoveCredential/password",
                new { controller = "Users", action = "RemovePassword" });

            routes.MapRoute(
                RouteName.RemoveCredential,
                "account/RemoveCredential/{credentialType}",
                new { controller = "Users", action = "RemoveCredential" });

            routes.MapRoute(
                RouteName.PasswordReset,
                "account/forgotpassword/{username}/{token}",
                new { controller = "Users", action = "ResetPassword", forgot = true });

            routes.MapRoute(
                RouteName.PasswordSet,
                "account/setpassword/{username}/{token}",
                new { controller = "Users", action = "ResetPassword", forgot = false });

            routes.MapRoute(
                RouteName.ConfirmAccount,
                "account/confirm/{username}/{token}",
                new { controller = "Users", action = "Confirm" });

            routes.MapRoute(
                RouteName.SubscribeToEmails,
                "account/subscribe",
                new { controller = "Users", action = "ChangeEmailSubscription", subscribe = true });

            routes.MapRoute(
                RouteName.UnsubscribeFromEmails,
                "account/unsubscribe",
                new { controller = "Users", action = "ChangeEmailSubscription", subscribe = false });

            routes.MapRoute(
                RouteName.Account,
                "account/{action}",
                new { controller = "Users", action = "Account" });

            routes.MapRoute(
                RouteName.CuratedFeed,
                "curated-feeds/{name}",
                new { controller = "CuratedFeeds", action = "CuratedFeed" });

            routes.MapRoute(
                RouteName.CuratedFeedListPackages,
                "curated-feeds/{curatedFeedName}/packages",
                new { controller = "CuratedFeeds", action = "ListPackages" });

            routes.MapRoute(
                RouteName.CreateCuratedPackageForm,
                "forms/add-package-to-curated-feed",
                new { controller = "CuratedPackages", action = "CreateCuratedPackageForm" });

            routes.MapRoute(
                RouteName.CuratedPackage,
                "curated-feeds/{curatedFeedName}/curated-packages/{curatedPackageId}",
                new { controller = "CuratedPackages", action = "CuratedPackage" });

            routes.MapRoute(
                RouteName.CuratedPackages,
                "curated-feeds/{curatedFeedName}/curated-packages",
                new { controller = "CuratedPackages", action = "CuratedPackages" });

            // TODO : Most of the routes are essentially of the format api/v{x}/*. We should refactor the code to vary them by the version.
            // V1 Routes
            // If the push url is /api/v1 then NuGet.Core would ping the path to resolve redirection.
            routes.MapRoute(
                "v1" + RouteName.VerifyPackageKey,
                "api/v1/verifykey/{id}/{version}",
                new {
                controller = "Api",
                action     = "VerifyPackageKey",
                id         = UrlParameter.Optional,
                version    = UrlParameter.Optional
            });

            var downloadRoute = routes.MapRoute(
                "v1" + RouteName.DownloadPackage,
                "api/v1/package/{id}/{version}",
                defaults: new {
                controller = "Api",
                action     = "GetPackageApi",
                version    = UrlParameter.Optional
            },
                constraints: new { httpMethod = new HttpMethodConstraint("GET") });

            routes.MapRoute(
                "v1" + RouteName.PushPackageApi,
                "v1/PackageFiles/{apiKey}/nupkg",
                defaults: new { controller = "Api", action = "PushPackageApi" },
                constraints: new { httpMethod = new HttpMethodConstraint("POST") });

            routes.MapRoute(
                "v1" + RouteName.DeletePackageApi,
                "v1/Packages/{apiKey}/{id}/{version}",
                new { controller = "Api", action = "DeletePackages" });

            routes.MapRoute(
                "v1" + RouteName.PublishPackageApi,
                "v1/PublishedPackages/Publish",
                new { controller = "Api", action = "PublishPackage" });

            // Redirected Legacy Routes

            routes.Redirect(
                r => r.MapRoute(
                    "ReportAbuse",
                    "Package/ReportAbuse/{id}/{version}",
                    new { controller = "Packages", action = "ReportAbuse" }),
                permanent: true).To(packageVersionActionRoute);

            routes.Redirect(
                r => r.MapRoute(
                    "PackageActions",
                    "Package/{action}/{id}",
                    new { controller = "Packages", action = "ContactOwners" },
                    // This next bit looks bad, but it's not. It will never change because
                    // it's mapping the legacy routes to the new better routes.
                    new { action = "ContactOwners|ManagePackageOwners" }),
                permanent: true).To(packageActionRoute);

            routes.Redirect(
                r => r.MapRoute(
                    RouteName.ListPackages,
                    "List/Packages",
                    new { controller = "Packages", action = "ListPackages" }),
                permanent: true).To(packageListRoute);

            routes.Redirect(
                r => r.MapRoute(
                    RouteName.DisplayPackage,
                    "List/Packages/{id}/{version}",
                    new { controller = "Packages", action = "DisplayPackage", version = UrlParameter.Optional }),
                permanent: true).To(packageDisplayRoute);

            routes.Redirect(
                r => r.MapRoute(
                    RouteName.NewSubmission,
                    "Contribute/NewSubmission",
                    new { controller = "Packages", action = "UploadPackage" }),
                permanent: true).To(uploadPackageRoute);

            routes.Redirect(
                r => r.MapRoute(
                    "LegacyDownloadRoute",
                    "v1/Package/Download/{id}/{version}",
                    new { controller = "Api", action = "GetPackageApi", version = UrlParameter.Optional }),
                permanent: true).To(downloadRoute);
        }
Exemplo n.º 38
0
        /// <summary>
        /// Provides a way to define routes for Razor web pages.
        /// </summary>
        /// <param name="routeCollection">The collection of routes.</param>
        /// <param name="name">The name of the route</param>
        /// <param name="url">The URL pattern for the route.</param>
        /// <param name="path">The virtual path of the web page.</param>
        /// <param name="defaults">The values to use if the URL does not contain all the parameters.</param>
        /// <param name="constraints">A regular expression that specifies valid values for a URL parameter.</param>
        public static void MapWebPageRoute(this RouteCollection routeCollection, string name, string url, string path, object defaults = null, object constraints = null)
        {
            var item = new Route(url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), new WebPagesRouteHandler(path));

            routeCollection.Add(name, item);
        }
Exemplo n.º 39
0
        private static void RegisterRoutes(RouteCollection routes)
        {
            var DEFAULT_JSON = new RouteValueDictionary {
                { "accept", JsonConstants.MediaType }
            };

            // Navigation  --------------------------------------------------

            routes.Add(new RegexRoute(@"/go/(?<sector>[^/]+)", new RedirectRouteHandler("/?sector={sector}", statusCode: 302)));
            routes.Add(new RegexRoute(@"/go/(?<sector>[^/]+)/(?<hex>[0-9]{4})", new RedirectRouteHandler("/?sector={sector}&hex={hex}", statusCode: 302)));
            routes.Add(new RegexRoute(@"/go/(?<sector>[^/]+)/(?<subsector>[^/]+)", new RedirectRouteHandler("/?sector={sector}&subsector={subsector}", statusCode: 302)));

            routes.Add(new RegexRoute(@"/booklet/(?<sector>[^/]+)", new RedirectRouteHandler("/make/booklet?sector={sector}", statusCode: 302)));
            routes.Add(new RegexRoute(@"/sheet/(?<sector>[^/]+)/(?<hex>[0-9]{4})", new RedirectRouteHandler("/world?sector={sector}&hex={hex}", statusCode: 302)));

            // Administration -----------------------------------------------

            routes.Add(new RegexRoute(@"/admin/admin", new GenericRouteHandler(typeof(AdminHandler))));
            routes.Add(new RegexRoute(@"/admin/flush", new GenericRouteHandler(typeof(AdminHandler)),
                                      new RouteValueDictionary(new { action = "flush" })));
            routes.Add(new RegexRoute(@"/admin/reindex", new GenericRouteHandler(typeof(AdminHandler)),
                                      new RouteValueDictionary(new { action = "reindex" })));
            routes.Add(new RegexRoute(@"/admin/profile", new GenericRouteHandler(typeof(AdminHandler)),
                                      new RouteValueDictionary(new { action = "profile" })));
            routes.Add(new RegexRoute(@"/admin/codes", new GenericRouteHandler(typeof(CodesHandler))));
            routes.Add(new RegexRoute(@"/admin/dump", new GenericRouteHandler(typeof(DumpHandler))));
            routes.Add(new RegexRoute(@"/admin/errors", new GenericRouteHandler(typeof(ErrorsHandler))));
            routes.Add(new RegexRoute(@"/admin/overview", new GenericRouteHandler(typeof(OverviewHandler))));

            // Search -------------------------------------------------------

            routes.Add(new RegexRoute(@"/api/search", new GenericRouteHandler(typeof(SearchHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/api/route", new GenericRouteHandler(typeof(RouteHandler)), DEFAULT_JSON));

#if LEGACY_ASPX
            routes.Add(new RegexRoute(@"/Search.aspx", new GenericRouteHandler(typeof(SearchHandler)), caseInsensitive: true));
#endif

            // Rendering ----------------------------------------------------

            routes.Add(new RegexRoute(@"/api/jumpmap", new GenericRouteHandler(typeof(JumpMapHandler))));
            routes.Add(new RegexRoute(@"/api/poster", new GenericRouteHandler(typeof(PosterHandler))));
            routes.Add(new RegexRoute(@"/api/poster/(?<sector>[^/]+)", new GenericRouteHandler(typeof(PosterHandler))));
            routes.Add(new RegexRoute(@"/api/poster/(?<sector>[^/]+)/(?<quadrant>(?:alpha|beta|gamma|delta))", new GenericRouteHandler(typeof(PosterHandler))));
            routes.Add(new RegexRoute(@"/api/poster/(?<sector>[^/]+)/(?<subsector>[^/]+)", new GenericRouteHandler(typeof(PosterHandler))));
            routes.Add(new RegexRoute(@"/api/tile", new GenericRouteHandler(typeof(TileHandler))));
#if LEGACY_ASPX
            routes.Add(new RegexRoute(@"/JumpMap.aspx", new GenericRouteHandler(typeof(JumpMapHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/Poster.aspx", new GenericRouteHandler(typeof(PosterHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/Tile.aspx", new GenericRouteHandler(typeof(TileHandler)), caseInsensitive: true));
#endif

            // Location Queries ---------------------------------------------

            routes.Add(new RegexRoute(@"/api/coordinates", new GenericRouteHandler(typeof(CoordinatesHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/api/credits", new GenericRouteHandler(typeof(CreditsHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/api/jumpworlds", new GenericRouteHandler(typeof(JumpWorldsHandler)), DEFAULT_JSON));
#if LEGACY_ASPX
            routes.Add(new RegexRoute(@"/Coordinates.aspx", new GenericRouteHandler(typeof(CoordinatesHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/Credits.aspx", new GenericRouteHandler(typeof(CreditsHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/JumpWorlds.aspx", new GenericRouteHandler(typeof(JumpWorldsHandler)), caseInsensitive: true));
#endif

            // Data Retrieval - API-centric ---------------------------------

            routes.Add(new RegexRoute(@"/api/universe", new GenericRouteHandler(typeof(UniverseHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/api/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }
            }));
            routes.Add(new RegexRoute(@"/api/sec/(?<sector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }
            }));
            routes.Add(new RegexRoute(@"/api/sec/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }, { "metadata", 0 }
            }));
            routes.Add(new RegexRoute(@"/api/sec/(?<sector>[^/]+)/(?<subsector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }, { "metadata", 0 }
            }));
            routes.Add(new RegexRoute(@"/api/metadata", new GenericRouteHandler(typeof(SectorMetaDataHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/api/metadata/(?<sector>[^/]+)", new GenericRouteHandler(typeof(SectorMetaDataHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/api/msec", new GenericRouteHandler(typeof(MSECHandler))));
            routes.Add(new RegexRoute(@"/api/msec/(?<sector>[^/]+)", new GenericRouteHandler(typeof(MSECHandler))));
#if LEGACY_ASPX
            routes.Add(new RegexRoute(@"/Universe.aspx", new GenericRouteHandler(typeof(UniverseHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/SEC.aspx", new GenericRouteHandler(typeof(SECHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/SectorMetaData.aspx", new GenericRouteHandler(typeof(SectorMetaDataHandler)), caseInsensitive: true));
            routes.Add(new RegexRoute(@"/MSEC.aspx", new GenericRouteHandler(typeof(MSECHandler)), caseInsensitive: true));
#endif

            // Data Retrieval - RESTful -------------------------------------

            routes.Add(new RegexRoute(@"/data", new GenericRouteHandler(typeof(UniverseHandler)), DEFAULT_JSON));

            // Sector, e.g. /data/Spinward Marches
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/sec", new GenericRouteHandler(typeof(SECHandler))));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "TabDelimited" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/coordinates", new GenericRouteHandler(typeof(CoordinatesHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/credits", new GenericRouteHandler(typeof(CreditsHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/metadata", new GenericRouteHandler(typeof(SectorMetaDataHandler)))); // NOTE: XML by default
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/msec", new GenericRouteHandler(typeof(MSECHandler))));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/image", new GenericRouteHandler(typeof(PosterHandler))));

            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/booklet", new RedirectRouteHandler("/make/booklet?sector={sector}", statusCode: 302)));

            // Quadrant, e.g. /data/Spinward Marches/Alpha
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }, { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "TabDelimited" }, { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<quadrant>alpha|beta|gamma|delta)/image", new GenericRouteHandler(typeof(PosterHandler))));

            // Subsector by Index, e.g. /data/Spinward Marches/C
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }, { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "TabDelimited" }, { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[A-Pa-p])/image", new GenericRouteHandler(typeof(PosterHandler))));

            // World e.g. /data/Spinward Marches/1910
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})", new GenericRouteHandler(typeof(JumpWorldsHandler)), new RouteValueDictionary {
                { "accept", JsonConstants.MediaType }, { "jump", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/coordinates", new GenericRouteHandler(typeof(CoordinatesHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/credits", new GenericRouteHandler(typeof(CreditsHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/jump/(?<jump>\d+)", new GenericRouteHandler(typeof(JumpWorldsHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/image", new GenericRouteHandler(typeof(JumpMapHandler)), new RouteValueDictionary {
                { "jump", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/jump/(?<jump>\d+)/image", new GenericRouteHandler(typeof(JumpMapHandler))));

            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<hex>[0-9]{4})/sheet", new RedirectRouteHandler("/world?sector={sector}&hex={hex}", statusCode: 302)));

            // Subsector by Name e.g. /data/Spinward Marches/Regina
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "SecondSurvey" }, { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)/sec", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)/tab", new GenericRouteHandler(typeof(SECHandler)), new RouteValueDictionary {
                { "type", "TabDelimited" }, { "metadata", "0" }
            }));
            routes.Add(new RegexRoute(@"/data/(?<sector>[^/]+)/(?<subsector>[^/]+)/image", new GenericRouteHandler(typeof(PosterHandler))));

            // T5SS Stock Data -------------------------------------

            routes.Add(new RegexRoute(@"/t5ss/allegiances", new GenericRouteHandler(typeof(AllegianceCodesHandler)), DEFAULT_JSON));
            routes.Add(new RegexRoute(@"/t5ss/sophonts", new GenericRouteHandler(typeof(SophontCodesHandler)), DEFAULT_JSON));
        }
Exemplo n.º 40
0
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.Add("SenparcWebSocketRoute", new Route("SenparcWebSocket", new WebSocketRouteHandler()));//SenparcWebSocket/{app}
 }
Exemplo n.º 41
0
        public static void MapSeoRoutes(this RouteCollection routes)
        {
            var pageRoute =
                new NormalizeRoute(
                    new PageRoute(
                        Constants.PageRoute,
                        new RouteValueDictionary
            {
                { "controller", "Page" },
                { "action", "DisplayPageAsync" },
                //{ Constants.Language, UrlParameter.Optional }
            },
                        new RouteValueDictionary
            {
                { Constants.Language, new LanguageRouteConstraint() },
                { Constants.Store, new StoreRouteConstraint() },
                { Constants.Page, new PageRouteConstraint() }
            },
                        new RouteValueDictionary {
                { "namespaces", new[] { "VirtoCommerce.Web.Controllers" } }
            },
                        new MvcRouteHandler()));

            var itemRoute =
                new NormalizeRoute(
                    new ItemRoute(
                        Constants.ItemRoute,
                        new RouteValueDictionary
            {
                { "controller", "Product" },
                { "action", "ProductByKeywordAsync" },
                //{ Constants.Language, UrlParameter.Optional }
            },
                        new RouteValueDictionary
            {
                { Constants.Language, new LanguageRouteConstraint() },
                { Constants.Store, new StoreRouteConstraint() },
                { Constants.Category, new CategoryRouteConstraint() },
                { Constants.Item, new ItemRouteConstraint() }
            },
                        new RouteValueDictionary {
                { "namespaces", new[] { "VirtoCommerce.Web.Controllers" } }
            },
                        new MvcRouteHandler()));

            var categoryRoute =
                new NormalizeRoute(
                    new CategoryRoute(
                        Constants.CategoryRoute,
                        new RouteValueDictionary
            {
                { "controller", "Collections" },
                { "action", "GetCollectionByKeywordAsync" },
                //{ Constants.Language, UrlParameter.Optional },
                { Constants.Tags, UrlParameter.Optional },
            },
                        new RouteValueDictionary
            {
                { Constants.Language, new LanguageRouteConstraint() },
                { Constants.Store, new StoreRouteConstraint() },
                { Constants.Category, new CategoryRouteConstraint() }
            },
                        new RouteValueDictionary {
                { "namespaces", new[] { "VirtoCommerce.Web.Controllers" } }
            },
                        new MvcRouteHandler()));

            var storeRoute =
                new NormalizeRoute(
                    new StoreRoute(
                        Constants.StoreRoute,
                        new RouteValueDictionary {
                { "controller", "Home" }, { "action", "Index" }
            },
                        new RouteValueDictionary
            {
                { Constants.Language, new LanguageRouteConstraint() },
                { Constants.Store, new StoreRouteConstraint() }
            },
                        new RouteValueDictionary {
                { "namespaces", new[] { "VirtoCommerce.Web.Controllers" } }
            },
                        new MvcRouteHandler()));

            //Legacy redirects
            routes.Redirect(r => r.MapRoute("old_Collection", string.Format("collections/{{{0}}}", Constants.Category))).To(categoryRoute,
                                                                                                                            x =>
            {
                //Expect to receive category code
                if (x.RouteData.Values.ContainsKey(Constants.Category))
                {
                    var client   = ClientContext.Clients.CreateBrowseClient();
                    var store    = SiteContext.Current.Shop.StoreId;
                    var language = SiteContext.Current.Language;
                    var category = Task.Run(() => client.GetCategoryByCodeAsync(store, language, x.RouteData.Values[Constants.Category].ToString())).Result;
                    if (category != null)
                    {
                        var model = category.AsWebModel();
                        return(new RouteValueDictionary {
                            { Constants.Category, model.Outline }
                        });
                    }
                }
                return(null);
            });


            var defaultRoute = new NormalizeRoute(
                new Route(string.Format("{0}/{{controller}}/{{action}}/{{id}}", Constants.StoreRoute),
                          new RouteValueDictionary {
                { "id", UrlParameter.Optional },
                { "action", "Index" }
            },
                          new RouteValueDictionary
            {
                { Constants.Language, new LanguageRouteConstraint() },
                { Constants.Store, new StoreRouteConstraint() }
            },
                          new RouteValueDictionary {
                { "namespaces", new[] { "VirtoCommerce.Web.Controllers" } }
            },
                          new MvcRouteHandler()));

            routes.Add("Page", pageRoute);
            routes.Add("Item", itemRoute);
            routes.Add("Category", categoryRoute);
            routes.Add("Store", storeRoute);

            //Other actions
            routes.Add("RelativeDefault", defaultRoute);
        }
Exemplo n.º 42
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);

            //                    IMPORTANT: DATA MODEL REGISTRATION
            // Uncomment this line to register an ADO.NET Entity Framework model for ASP.NET Dynamic Data.
            // Set ScaffoldAllTables = true only if you are sure that you want all tables in the
            // data model to support a scaffold (i.e. templates) view. To control scaffolding for
            // individual tables, create a partial class for the table and apply the
            // [ScaffoldTable(true)] attribute to the partial class.
            // Note: Make sure that you change "YourDataContextType" to the name of the data context
            // class in your application.
            // See http://go.microsoft.com/fwlink/?LinkId=257395 for more information on how to register Entity Data Model with Dynamic Data
            // DefaultModel.RegisterContext(() =>
            // {
            //    return ((IObjectContextAdapter)new YourDataContextType()).ObjectContext;
            // }, new ContextConfiguration() { ScaffoldAllTables = false });

            DefaultModel.RegisterContext
            (
                () =>
            {
                return(((System.Data.Entity.Infrastructure.IObjectContextAdapter)(new DataModelContainer())).ObjectContext);
            },
                new ContextConfiguration()
            {
                ScaffoldAllTables = true
            }
                //new ContextConfiguration() { ScaffoldAllTables = false }
            );

            // The following registration should be used if YourDataContextType does not derive from DbContext
            // DefaultModel.RegisterContext(typeof(YourDataContextType), new ContextConfiguration() { ScaffoldAllTables = false });

            // The following statement supports separate-page mode, where the List, Detail, Insert, and
            // Update tasks are performed by using separate pages. To enable this mode, uncomment the following
            // route definition, and comment out the route definitions in the combined-page mode section that follows.
            routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
            {
                //Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                Constraints = new RouteValueDictionary(new { action = "List|Details" }),
                Model       = DefaultModel
            });

            // The following statements support combined-page mode, where the List, Detail, Insert, and
            // Update tasks are performed by using the same page. To enable this mode, uncomment the
            // following routes and comment out the route definition in the separate-page mode section above.
            //routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
            //    Action = PageAction.List,
            //    ViewName = "ListDetails",
            //    Model = DefaultModel
            //});

            //routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
            //    Action = PageAction.Details,
            //    ViewName = "ListDetails",
            //    Model = DefaultModel
            //});
        }
Exemplo n.º 43
0
 public static void AddServiceHandler <T>(this RouteCollection routes, string route) where T : class, IHttpHandler
 {
     routes.Add(new Route(route, new ServiceBasedRouteHandler <T>()));
 }
Exemplo n.º 44
0
        public void Publish(IEnumerable <RouteDescriptor> routes, Func <IDictionary <string, object>, Task> pipeline = null)
        {
            var routesArray = routes
                              .OrderByDescending(r => r.Priority)
                              .ToArray();

            // this is not called often, but is intended to surface problems before
            // the actual collection is modified
            var preloading = new RouteCollection();

            foreach (var routeDescriptor in routesArray)
            {
                // extract the WebApi route implementation
                var httpRouteDescriptor = routeDescriptor as HttpRouteDescriptor;
                if (httpRouteDescriptor != null)
                {
                    var httpRouteCollection = new RouteCollection();
                    httpRouteCollection.MapHttpRoute(httpRouteDescriptor.Name, httpRouteDescriptor.RouteTemplate, httpRouteDescriptor.Defaults, httpRouteDescriptor.Constraints);
                    routeDescriptor.Route = httpRouteCollection.First();
                }

                preloading.Add(routeDescriptor.Name, routeDescriptor.Route);
            }

            using (_routeCollection.GetWriteLock())
            {
                // HACK: For inserting names in internal dictionary when inserting route to RouteCollection.
                var routeCollectionType = typeof(RouteCollection);
                var namedMap            = (Dictionary <string, RouteBase>)routeCollectionType.GetField("_namedMap", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_routeCollection);

                // new routes are added
                foreach (var routeDescriptor in routesArray)
                {
                    // Loading session state information.
                    var    defaultSessionState = SessionStateBehavior.Default;
                    object extensionId         = default(object);
                    if (routeDescriptor.Route is System.Web.Routing.Route)
                    {
                        var route = routeDescriptor.Route as System.Web.Routing.Route;
                        if (route.DataTokens != null && route.DataTokens.TryGetValue("area", out extensionId) ||
                            route.Defaults != null && route.Defaults.TryGetValue("area", out extensionId))
                        {
                            //TODO Extension Handler
                            //extensionDescriptor = _extensionManager.GetExtension(extensionId.ToString());
                        }
                    }
                    var shellRoute = new ShellRoute(routeDescriptor.Route, _iocManager, pipeline)
                    {
                        IsHttpRoute = routeDescriptor is HttpRouteDescriptor,
                        // SessionState = sessionStateBehavior
                    };
                    var area = extensionId != null?extensionId.ToString() : string.Empty;

                    if (!namedMap.Any(t => t.Key == area))

                    {
                        if (routeDescriptor.Route != null)
                        {
                            _routeCollection.Add(shellRoute);
                        }
                        namedMap[routeDescriptor.Name] = shellRoute;
                    }
                }
            }
        }
Exemplo n.º 45
0
 public static void AddGenericHandler <T>(this RouteCollection routes, string route) where T : IHttpHandler, new()
 {
     routes.Add(new Route(route, new GenericRouteHandler <T>()));
 }
Exemplo n.º 46
0
        private static void RegisterRoutes(RouteCollection routes)
        {
            routes.Add(new Route("", new StopRoutingHandler()));
            routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));

            routes.Add(new Route("{Template}/{TemplateName}/images/{imagefolder}/{filename}.jpg", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{imagefolder}/{filename}.png", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{imagefolder}/{filename}.gif", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{imagefolder}/{filename}.bmp", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{filename}.png", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{filename}.jpg", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{filename}.gif", new StopRoutingHandler()));
            routes.Add(new Route("{Template}/{TemplateName}/images/{filename}.bmp", new StopRoutingHandler()));

            routes.Add("SageFrameRouting0", new Route("portal/{PortalSEOName}/category/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("SageFrameRouting01", new Route("portal/{PortalSEOName}/item/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("SageFrameRouting02", new Route("portal/{PortalSEOName}/tags/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("SageFrameRouting03", new Route("portal/{PortalSEOName}/tagsitems/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("SageFrameRouting04", new Route("portal/{PortalSEOName}/search/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
            routes.Add("SageFrameRouting05", new Route("portal/{PortalSEOName}/option/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRouting1", new Route("portal/{PortalSEOName}/{UserModuleID}/Sagin/{ControlType}/{*PagePath}", new SageFrameRouteHandler("~/Sagin/ManagePage.aspx")));
            routes.Add("SageFrameRouting2", new Route("{UserModuleID}/Sagin/{ControlType}/{*PagePath}", new SageFrameRouteHandler("~/Sagin/ManagePage.aspx")));
            routes.Add("SageFrameRouting3", new System.Web.Routing.Route("portal/{PortalSEOName}/admin/{*PagePath}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRouting4", new System.Web.Routing.Route("portal/{PortalSEOName}/Super-User/{*PagePath}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRouting10", new System.Web.Routing.Route("admin/{*PagePath}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRouting11", new System.Web.Routing.Route("Admin.aspx", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRouting5", new System.Web.Routing.Route("Super-User.aspx", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRouting6", new System.Web.Routing.Route("Super-User/{*PagePath}", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRouting7", new System.Web.Routing.Route("portal/{PortalSEOName}/{*PagePath}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            //routes.Add("SageFrameRouting8", new System.Web.Routing.Route("/Admin.aspx", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            //routes.Add("SageFrameRouting9", new System.Web.Routing.Route("/Super-User.aspx", new SageFrameRouteHandler("~/Sagin/Default.aspx")));
            routes.Add("SageFrameRoutingCategory", new Route("category/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRoutingProductDetail", new Route("item/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRoutingTagsAll", new Route("tags/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRoutingTagsItems", new Route("tagsitems/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRoutingSearchTerm", new Route("search/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRoutingShoppingOption", new Route("option/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRoutingCouponsAll", new Route("coupons/{*uniqueWord}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));

            routes.Add("SageFrameRouting9", new Route("{*PagePath}", new SageFrameRouteHandler("~/" + CommonHelper.DefaultPage)));
        }
Exemplo n.º 47
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
            routes.IgnoreRoute("{*Content}", new { imgs = @"(.*/)?Content(/.*)?" });
            routes.IgnoreRoute("{*Scripts}", new { scripts = @"(.*/)?Scripts(/.*)?" });

            routes.MapRoute(RouteName.Home, "", MVC.Pages.Home());

            routes.MapRouteSeo(
                RouteName.InstallerBatchFile, "installChocolatey.cmd", new
            {
                controller = "Pages",
                Action     = "InstallerBatchFile"
            });

            routes.MapRouteSeo(
                RouteName.Features, "features", new
            {
                controller = "Pages",
                Action     = "Features"
            });

            routes.MapRouteSeo(
                RouteName.About, "about", new
            {
                controller = "Pages",
                Action     = "About"
            });

            routes.MapRouteSeo(
                RouteName.Notice, "notice", new
            {
                controller = "Pages",
                Action     = "Notice"
            });

            var pricingRoute = routes.MapRoute(
                RouteName.Pricing, "pricing", new
            {
                controller = "Pages",
                Action     = "Pricing"
            });

            routes.Redirect(r => r.MapRoute(RouteName.Compare, "compare")).To(pricingRoute);

            routes.MapRouteSeo(
                RouteName.Install, "install", new
            {
                controller = "Pages",
                Action     = "Install"
            });

            routes.MapRouteSeo(
                RouteName.Business, "business", new
            {
                controller = "Pages",
                Action     = "Business"
            });

            routes.MapRouteSeo(
                RouteName.FAQ, "faq", new
            {
                controller = "Pages",
                Action     = "FAQ"
            });

            routes.MapRouteSeo(
                RouteName.Kickstarter, "kickstarter", new
            {
                controller = "Pages",
                Action     = "Kickstarter"
            });

            routes.MapRouteSeo(
                RouteName.Terms, "terms", new
            {
                controller = "Pages",
                Action     = "Terms"
            });

            routes.MapRouteSeo(
                RouteName.Privacy, "privacy", new
            {
                controller = "Pages",
                Action     = "Privacy"
            });

            routes.MapRouteSeo(
                RouteName.MediaKit, "mediakit", new
            {
                controller = "Pages",
                Action     = "MediaKit"
            });

            routes.MapRouteSeo(
                RouteName.Company, "company", new
            {
                controller = "Pages",
                Action     = "Company"
            });

            routes.MapRouteSeo(
                RouteName.ContactUs, "contact", new
            {
                controller = "Pages",
                Action     = "ContactUs"
            });

            routes.MapRouteSeo(
                RouteName.Support, "support", new
            {
                controller = "Pages",
                Action     = "Support"
            });

            routes.MapRouteSeo(
                RouteName.ReportIssue, "bugs", new
            {
                controller = "Pages",
                Action     = "ReportIssue"
            });

            routes.MapRouteSeo(
                RouteName.Press, "press", new
            {
                controller = "Pages",
                Action     = "Press"
            });

            routes.MapRouteSeo(
                RouteName.Partner, "partner", new
            {
                controller = "Pages",
                Action     = "Partner"
            });

            routes.MapRouteSeo(
                RouteName.Security, "security", new
            {
                controller = "Pages",
                Action     = "Security"
            });

            routes.MapRouteSeo(
                RouteName.BlogHome,
                "blog/",
                new { controller = "Blog", action = "Index" }
                );

            routes.MapRouteSeo(
                RouteName.BlogArticle,
                "blog/{articleName}",
                new { controller = "Blog", action = "Article" }
                );

            routes.MapRouteSeo(
                RouteName.Docs,
                "docs/{docName}",
                new { controller = "Documentation", action = "Documentation", docName = "home" }
                );

            routes.MapRoute(RouteName.Stats, "stats", MVC.Pages.Stats());

            routes.MapRoute(
                "rss feed", "feed.rss", new
            {
                controller = "RSS",
                Action     = "feed.rss"
            });

            routes.MapRoute(
                "blog rss feed", "blog.rss", new
            {
                controller = "Blog",
                Action     = "blog.rss"
            });

            routes.Add(new JsonRoute("json/{controller}"));

            routes.MapRoute(RouteName.Policies, "policies/{action}", MVC.Pages.Terms());

            var packageListRoute = routes.MapRoute(RouteName.ListPackages, "packages", MVC.Packages.ListPackages());

            routes.MapRoute(
                RouteName.NotifyComment, "packages/{packageId}/notify-comment", new
            {
                controller = MVC.Packages.Name,
                action     = "NotifyMaintainersOfAddedComment"
            });

            var uploadPackageRoute = routes.MapRoute(RouteName.UploadPackage, "packages/upload", MVC.Packages.UploadPackage());

            routes.MapRoute(RouteName.VerifyPackage, "packages/verify-upload", MVC.Packages.VerifyPackage());

            routes.MapRoute(RouteName.CancelUpload, "packages/cancel-upload", MVC.Packages.CancelUpload());

            routes.MapRoute(
                RouteName.PackageOwnerConfirmation, "packages/{id}/owners/{username}/confirm/{token}", new
            {
                controller = MVC.Packages.Name,
                action     = "ConfirmOwner"
            });

            // We need the following two routes (rather than just one) due to Routing's
            // Consecutive Optional Parameter bug. :(
            var packageDisplayRoute = routes.MapRoute(
                RouteName.DisplayPackage, "packages/{id}/{version}", MVC.Packages.DisplayPackage().AddRouteValue("version", UrlParameter.Optional), null /*defaults*/, new
            {
                version = new VersionRouteConstraint()
            });

            var packageVersionActionRoute = routes.MapRoute(
                RouteName.PackageVersionAction, "packages/{id}/{version}/{action}", new
            {
                controller = MVC.Packages.Name
            }, new
            {
                version = new VersionRouteConstraint()
            });

            var packageActionRoute = routes.MapRoute(
                RouteName.PackageAction, "packages/{id}/{action}", new
            {
                controller = MVC.Packages.Name
            });

            var resendRoute = routes.MapRoute("ResendConfirmation", "account/ResendConfirmation", MVC.Users.ResendConfirmation());

            //Redirecting v1 Confirmation Route
            routes.Redirect(r => r.MapRoute("v1Confirmation", "Users/Account/ChallengeEmail")).To(resendRoute);

            routes.MapRoute(
                RouteName.Authentication, "users/account/{action}", new
            {
                controller = MVC.Authentication.Name
            });

            routes.MapRoute(RouteName.Profile, "profiles/{username}", MVC.Users.Profiles());

            routes.MapRoute(RouteName.PasswordReset, "account/{action}/{username}/{token}", MVC.Users.ResetPassword());

            routes.MapRoute(RouteName.Account, "account/{action}", MVC.Users.Account());

            routes.MapRoute(
                "site" + RouteName.DownloadPackage, "packages/{id}/{version}/DownloadPackage", MVC.Api.GetPackage(), defaults: new
            {
                version = UrlParameter.Optional
            }, constraints: new
            {
                httpMethod = new HttpMethodConstraint("GET")
            });

            // V1 Routes
            routes.MapRoute("v1Legacy" + RouteName.PushPackageApi, "PackageFiles/{apiKey}/nupkg", MVC.Api.CreatePackagePost());
            routes.MapRoute("v1Legacy" + RouteName.PublishPackageApi, "PublishedPackages/Publish", MVC.Api.PublishPackage());

            // V2 routes
            routes.MapRoute(
                "v2" + RouteName.VerifyPackageKey, "api/v2/verifykey/{id}/{version}", MVC.Api.VerifyPackageKey(), defaults: new
            {
                id      = UrlParameter.Optional,
                version = UrlParameter.Optional
            });

            routes.MapRoute(
                "v2" + RouteName.DownloadPackage, "api/v2/package/{id}/{version}", MVC.Api.GetPackage(), defaults: new
            {
                version = UrlParameter.Optional
            }, constraints: new
            {
                httpMethod = new HttpMethodConstraint("GET")
            });

            routes.MapRoute(
                "v2" + RouteName.PushPackageApi, "api/v2/package", MVC.Api.CreatePackagePut(), defaults: null, constraints: new
            {
                httpMethod = new HttpMethodConstraint("PUT")
            });

            routes.MapRoute(
                "v2" + RouteName.DeletePackageApi, "api/v2/package/{id}/{version}", MVC.Api.DeletePackage(), defaults: null, constraints: new
            {
                httpMethod = new HttpMethodConstraint("DELETE")
            });

            routes.MapRoute(
                "v2" + RouteName.PublishPackageApi, "api/v2/package/{id}/{version}", MVC.Api.PublishPackage(), defaults: null, constraints: new
            {
                httpMethod = new HttpMethodConstraint("POST")
            });

            routes.MapServiceRoute(RouteName.V2ApiSubmittedFeed, "api/v2/submitted", typeof(V2SubmittedFeed));

            routes.MapRoute(
                "v2" + RouteName.TestPackageApi,
                "api/v2/test/{id}/{version}",
                MVC.Api.TestPackage(),
                defaults: null,
                constraints: new
            {
                httpMethod = new HttpMethodConstraint("POST")
            }
                );

            routes.MapRoute(
                "v2" + RouteName.ValidatePackageApi,
                "api/v2/validate/{id}/{version}",
                MVC.Api.ValidatePackage(),
                defaults: null,
                constraints: new
            {
                httpMethod = new HttpMethodConstraint("POST")
            }
                );

            routes.MapRoute(
                "v2" + RouteName.CleanupPackageApi,
                "api/v2/cleanup/{id}/{version}",
                MVC.Api.CleanupPackage(),
                defaults: null,
                constraints: new
            {
                httpMethod = new HttpMethodConstraint("POST")
            }
                );

            routes.MapRoute(
                "v2" + RouteName.DownloadCachePackageApi,
                "api/v2/cache/{id}/{version}",
                MVC.Api.DownloadCachePackage(),
                defaults: null,
                constraints: new
            {
                httpMethod = new HttpMethodConstraint("POST")
            }
                );

            routes.MapRoute(
                "v2" + RouteName.ScanPackageApi,
                "api/v2/scan/{id}/{version}",
                MVC.Api.ScanPackage(),
                defaults: null
                );

            routes.MapRoute("v2PackageIds", "api/v2/package-ids", MVC.Api.GetPackageIds());

            routes.MapRoute("v2PackageVersions", "api/v2/package-versions/{id}", MVC.Api.GetPackageVersions());

            routes.MapServiceRoute(RouteName.V2ApiFeed, "api/v2/", typeof(V2Feed));

            // Redirected Legacy Routes

            routes.Redirect(r => r.MapRoute("ReportAbuse", "Package/ReportAbuse/{id}/{version}", MVC.Packages.ReportAbuse()), permanent: true).To(packageVersionActionRoute);

            routes.Redirect(
                r => r.MapRoute(
                    "PackageActions", "Package/{action}/{id}", MVC.Packages.ContactOwners(), null /*defaults*/, // This next bit looks bad, but it's not. It will never change because
                    // it's mapping the legacy routes to the new better routes.
                    new
            {
                action = "ContactOwners|ManagePackageOwners"
            }), permanent: true).To(packageActionRoute);

            // TODO: this route looks broken as there is no EditPackage action
            //routes.Redirect(
            //    r => r.MapRoute(
            //        "EditPackage",
            //        "Package/Edit/{id}/{version}",
            //        new { controller = PackagesController.ControllerName, action = "EditPackage" }),
            //    permanent: true).To(packageVersionActionRoute);

            routes.Redirect(r => r.MapRoute(RouteName.ListPackages, "List/Packages", MVC.Packages.ListPackages()), permanent: true).To(packageListRoute);

            routes.Redirect(r => r.MapRoute(RouteName.DisplayPackage, "List/Packages/{id}/{version}", MVC.Packages.DisplayPackage().AddRouteValue("version", UrlParameter.Optional)), permanent: true)
            .To(packageDisplayRoute);

            routes.Redirect(r => r.MapRoute(RouteName.NewSubmission, "Contribute/NewSubmission", MVC.Packages.UploadPackage()), permanent: true).To(uploadPackageRoute);
        }
Exemplo n.º 48
0
        public void GetActionPath_Action_3()
        {
            MetaModel m = MetaModel.Default;

            var req = new FakeHttpWorkerRequest();
            var ctx = new HttpContext(req);

            HttpContext.Current = ctx;

            RouteCollection routes = RouteTable.Routes;

            routes.Clear();
            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action       = PageAction.List,
                ViewName     = "ListDetails",
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            });

            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action       = PageAction.Details,
                ViewName     = "ListDetails",
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            });

            MetaTable t = m.Tables[TestDataContext.TableFooWithDefaults];

            Assert.AreEqual(t.Model, m, "#A0");
            Assert.AreEqual(Utils.BuildActionName(t, "ListDetails"), t.GetActionPath(PageAction.Details), "#A1");
            Assert.AreEqual(Utils.BuildActionName(t, "ListDetails"), t.GetActionPath(PageAction.List), "#A2");

            // Missing routes
            Assert.AreEqual(String.Empty, t.GetActionPath(PageAction.Edit), "#A3");
            Assert.AreEqual(String.Empty, t.GetActionPath(PageAction.Insert), "#A4");

            // Add routes for the two above tests
            routes.Add(new DynamicDataRoute("{table}/EditInsert.aspx")
            {
                Action       = PageAction.Edit,
                ViewName     = "MyEditInsert",
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            });

            routes.Add(new DynamicDataRoute("{table}/InsertEdit.aspx")
            {
                Action       = PageAction.Insert,
                ViewName     = "MyEditInsert",
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            });

            Assert.AreEqual(Utils.BuildActionName(t, "ListDetails"), t.GetActionPath(PageAction.Details), "#B1");
            Assert.AreEqual(Utils.BuildActionName(t, "ListDetails"), t.GetActionPath(PageAction.List), "#B2");

            Assert.AreEqual(Utils.BuildActionName(t, "EditInsert"), t.GetActionPath(PageAction.Edit), "#B3");
            Assert.AreEqual(Utils.BuildActionName(t, "InsertEdit"), t.GetActionPath(PageAction.Insert), "#B4");
        }
Exemplo n.º 49
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add("Chrome", new ChromeRoute());//在这里添加我们自定义的路由过滤

            //注意传统路由和特性路由是可以混合使用的,建议把特性路由放在最前,因为特性路由相对于传统路由更加具体,传统路由更加宽泛自由
            routes.MapMvcAttributeRoutes();

            //设置 http://localhost:65034/welcome 指向Home中的Index()
            #region 书写格式
            //routes.MapRoute(
            //    name: "static",
            //    url: "welcome",
            //    defaults: new { controller = "Home", action = "Index" }
            //    );
            #endregion
            //简洁写的法
            //其实上面的写法就是把函数的形参名带着,在C#中的任何函数都是可以这样写的
            routes.MapRoute("static", "welcome", new { controller = "Home", action = "Index" });

            //路由的格式:控制器名/Action名/id值
            //注意我们这里设置的路由规则中controller和action和id都是加了个大括号,本质就是占位符,所以任何的controller和action都可以和这个路由规则匹配
            //而上面的路由规则中URL为welcome,匹配的就是welcome这个单词
            //设置控制器名默认为:Home,action默认为:Index,id为可选
            routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

            #region 路由顺序
            //注意每一个routes.MapRoute()的书写顺序是很讲究的,路由会按照先后顺序与之传入的URL进行匹配
            //比如说,我颠倒上面的static路由和Default路由
            //则当我输入“http://localhost:65034/welcome”就会出错,因为它也能与Default路由匹配,
            //但是只是符合Default路由的模式,并不能指向正确的action
            //按照Default路由匹配,它实际就是:http://localhost:65034/welcome/index  而实际是没有这个URL的
            //简而言之,路由匹配是自上而下的,匹配到第一个满足的即技术
            #endregion

            #region 路由约束
            //路由约束使用正则表达式
            //在特性路由中我们使用类似于{ id:int}的格式约束路由的某一个参数的类型
            //也可以使用正则表达式{year:regex{^\d{4}$}
            //传统路由使用一个单独的参数,且传统路由的约束在使用正则表达式的时候,可以省略"^""$"的位置匹配

            //这里注意:直接调试输入路由:localhost://65043/2020/08/11 会报错,因为该url首先匹配的是上面的control/action/id,所以会报错,因为我们就没有名称为2020的控制器
            //所有需要调试的话,可以先把上面的Default路由注释掉
            //注意:这里MapRoute()使用了四个参数,ctrl+shift+space查看智能提示理解了
            //第一个参数是路由名,第二个参数是路由规则,第三个参数就是默认路由,第四个参数就是路由规则的约束
            #endregion
            routes.MapRoute("blogs", "{year}/{month}/{day}", new { controller = "blog", action = "index" }, new { year = @"\d{4}", month = @"\d{2}", day = @"\d{2}" });


            routes.MapRoute("timeRoute", "{controller}/{action}_{year}_{month}_{day}", new { controller = "home", action = "time" }, new { year = @"\d{4}" });

            ///自定义路由约束
            ///约束一个路由只响应Get请求
            routes.MapRoute("onlyGet", "{controller}/{action}", null, new { httpMethod = new HttpMethodConstraint("GET") });


            //传统路由中约束类型,等价于特性路由中{id:int}
            //添加命名空间using System.Web.Mvc.Routing.Constraints;
            routes.MapRoute("onlyint", "{controller}/{action}/{id}", null, new { id = new IntRouteConstraint() });


            #region  择传统路由还是特性路由
            //1.首先二者可以混用
            //2.传统路由的优点:可以集中配置所有的路由,传统路由比特性路由灵活
            //3.特性路由的优点:路由和操作代码保存在一起
            #endregion


            //routes.MapRoute()的第一个参数是路由规则的名字
            //这个名字有什么用?我们可以在View页面使用Html辅助函数:@Html.RouteLink()来生成URL
            //也可以使用@Url.RouteUrl()来生成URL,具体见本项目中的CreateURL.cshtml
        }
Exemplo n.º 50
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapMvcAttributeRoutes();

            routes.MapRoute(
                name: "sitemap.xml",
                url: "sitemap.xml",
                defaults: new { controller = "Config", action = "SitemapXml" },
                namespaces: new[] { "x_nova.Areas.Admin.Controllers" }
                );

            routes.MapRoute(
                name: "robots.txt",
                url: "robots.txt",
                defaults: new { controller = "Config", action = "RobotsText" },
                namespaces: new[] { "x_nova.Controllers" }
                );

            routes.Add("ProductDetails", new SeoFriendlyRoute("products/{id}",
                                                              new RouteValueDictionary(new { controller = "Product", action = "Details" }),
                                                              new MvcRouteHandler()));

            routes.MapRoute(
                name: "news",
                url: "Post",
                defaults: new { controller = "Post", action = "Index" },
                namespaces: new[] { "x_nova_template.Controllers" }

                );
            routes.MapRoute(
                name: "photog",
                url: "Photogallery",
                defaults: new { controller = "PhotoGallery", action = "Index" },
                namespaces: new[] { "x_nova_template.Controllers" }

                );
            routes.MapRoute(
                name: "login",
                url: "Account/Login",
                defaults: new { controller = "Account", action = "Login" },
                namespaces: new[] { "x_nova_template.Controllers" }

                );


            /*      routes.MapRoute(
             * name: "port",
             * url: "{culture}/{controller}",
             * defaults: new { culture=CultureHelper.GetDefaultCulture(), controller = "Portfolio", action = "Index" },
             * namespaces: new[] { "Qualityequip.Controllers" }
             * );
             *    routes.MapRoute(
             * name: "order",
             * url: "{culture}/{controller}",
             * defaults: new { culture = CultureHelper.GetDefaultCulture(), controller = "MakeOrder", action = "Index" },
             * namespaces: new[] { "Qualityequip.Controllers" }
             * );*/
            IMenuRepository _repository = new MenuRepository();

            string[] excludeUrl = { "Post", "tobuy", "Home", "PhotoGallery" };
            foreach (var item in _repository.Menues.Where(x => !excludeUrl.Contains(x.Url)))
            {
                if (item.ParentId > 0)
                {
                    routes.MapRoute(
                        name: "Menu" + item.Id,
                        url: MenuController.GetMenuUrl(item.ParentId) + "/" + item.Url,
                        defaults: new { controller = "Dynamic", action = "Indexx", routes = item.Url },
                        namespaces: new[] { "x_nova_template.Controllers" }
                        );
                }
                else
                {
                    routes.MapRoute(
                        name: "Menu" + item.Id,
                        url: item.Url,
                        defaults: new { controller = "Dynamic", action = "Indexx", routes = item.Url },
                        namespaces: new[] { "x_nova_template.Controllers" }
                        );
                }
            }
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new[] { "x_nova_template.Controllers" }
                );
            routes.MapRoute(
                name: "home",
                url: "main",
                defaults: new { controller = "Home", action = "Index" },
                namespaces: new[] { "x_nova_template.Controllers" }
                );
            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Product", action = "ProdList", id=UrlParameter.Optional},
            //    namespaces: new[] { "x_nova_template.Controllers" }
            //);
        }
Exemplo n.º 51
0
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.Add("Default", new DefaultRoute());
 }
Exemplo n.º 52
0
 private void register(RouteCollection routes)
 {
     routes.Add(new ServiceRoute("v1/endpointService", new WebServiceHostFactory(), typeof(EndpointService)));
 }
Exemplo n.º 53
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "FederationMetadata",
                "FederationMetadata/2007-06/FederationMetadata.xml",
                new { controller = "FederationMetadata", action = "Generate" }
                );

            routes.MapRoute(
                "RelyingPartiesAdmin",
                "admin/relyingparties/{action}/{id}",
                new { controller = "RelyingPartiesAdmin", action = "Index", id = UrlParameter.Optional }
                );

            routes.MapRoute(
                "ClientCertificatesAdmin",
                "admin/clientcertificates/{action}/{userName}",
                new { controller = "ClientCertificatesAdmin", action = "Index", userName = UrlParameter.Optional }
                );

            routes.MapRoute(
                "DelegationAdmin",
                "admin/delegation/{action}/{userName}",
                new { controller = "DelegationAdmin", action = "Index", userName = UrlParameter.Optional }
                );

            routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new { controller = "^(?!issue).*" }
                );

            // ws-federation (mvc)
            routes.MapRoute(
                "wsfederation",
                "issue/wsfed",
                new { controller = "WSFederation", action = "issue" }
                );

            // jsnotify (mvc)
            routes.MapRoute(
                "jsnotify",
                "issue/jsnotify",
                new { controller = "JSNotify", action = "issue" }
                );

            // simple http (mvc)
            routes.MapRoute(
                "simplehttp",
                "issue/simple",
                new { controller = "SimpleHttp", action = "issue" }
                );

            // oauth wrap (mvc)
            routes.MapRoute(
                "wrap",
                "issue/wrap",
                new { controller = "Wrap", action = "issue" }
                );

            // oauth2 (mvc)
            routes.MapRoute(
                "oauth2",
                "issue/oauth2/{action}",
                new { controller = "OAuth2", action = "token" }
                );

            // ws-trust (wcf)
            routes.Add(new ServiceRoute(
                           "issue/wstrust",
                           new TokenServiceHostFactory(),
                           typeof(TokenServiceConfiguration)));
        }
Exemplo n.º 54
0
 public static void RegisterEpcisRoutes(RouteCollection routes)
 {
     routes.Add(new AppServiceRoute("Services/1.2/EpcisCapture", new NinjectServiceHostFactory(), typeof(CaptureService)));
     routes.Add(new AppServiceRoute("Services/1.2/EpcisQuery", new NinjectServiceHostFactory(), typeof(QueryService)));
 }
 /// <inheritdoc/>
 public override void Add(string name, IHttpRoute route)
 {
     _routeCollection.Add(name, route.ToRoute());
 }
Exemplo n.º 56
0
        public static Route AddRoute(this RouteCollection source, string name, Route item)
        {
            source.Add(name, item);

            return(item);
        }
Exemplo n.º 57
0
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.Add(new EncryptedRoute("EncodeUrl/{url}", null, null));
     RegisterRoutesInternal(routes);
 }
Exemplo n.º 58
0
        //***************************************************************************************************************************************
        /// <summary>

        /*
         *
         *  This method implements the loading of all URLs patterns that contain file extensions that need to be ignored and
         *  all URLs patterns that need to be processed:
         *
         *
         *  Example of patterns to process:
         *  routes.Add("ProfilesAliasPath2", new Route("{Param0}/{Param1}/{Param2}", new ProfilesRouteHandler()));
         *      The above example will register a URL pattern for processing by the Alias.aspx page.  When IIS makes a request,
         *      the URL pattern of http://domain.com/profile/person/32213, will trigger the .Net System.Web.Routing library to call ProfilesRouteHandler.GetHttpHandler(RequestContext requestContext){}.  This method will process the URL pattern into parameters and load the HttpContext.Current.Items hash table and then direct the request to the Alias.aspx page for processing.
         *
         */

        /// </summary>
        /// <param name="routes">RouteTable.Routes is passed as a RouteCollection by ref used to store all routes in the routing framework.</param>
        private static void RegisterRoutes(RouteCollection routes)
        {
            Framework.Utilities.DataIO d = new Framework.Utilities.DataIO();

            //The REST Paths are built based on the applications setup in the Profiles database.
            using (System.Data.SqlClient.SqlDataReader reader = d.GetRESTApplications())
            {
                int loop = 0;

                routes.RouteExistingFiles = false;

                // by UCSF
                routes.Add("RobotsTxt", new Route("robots.txt", new AspxHandler("~/RobotsTxt.aspx")));
                routes.Add("SiteMap", new Route("sitemap.xml", new AspxHandler("~/SiteMap.aspx")));

                while (reader.Read())
                {
                    routes.Add("ProfilesAliasPath0" + loop, new Route(reader[0].ToString(), new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath1" + loop, new Route(reader[0].ToString() + "/{Param1}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath2" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath3" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath4" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath5" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath6" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath7" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath8" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}", new ProfilesRouteHandler()));
                    routes.Add("ProfilesAliasPath9" + loop, new Route(reader[0].ToString() + "/{Param1}/{Param2}/{Param3}/{Param4}/{Param5}/{Param6}/{Param7}/{Param8}/{Param9}", new ProfilesRouteHandler()));

                    Framework.Utilities.DebugLogging.Log("REST PATTERN(s) CREATED FOR " + reader[0].ToString());
                    loop++;
                }
            }
        }
Exemplo n.º 59
0
        public void GetVirtualPath2()
        {
            var c = new RouteCollection();

            c.Add("Summary",
                  new MyRoute("summary/{action}-{type}/{page}", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Summary", action = "Index", page = 1 })
            }
                  );

            c.Add("Apis",
                  new MyRoute("apis/{apiname}", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Apis", action = "Index" })
            }
                  );

            c.Add("Single Report",
                  new MyRoute("report/{guid}", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Reports", action = "SingleReport" })
            }
                  );

            c.Add("Reports",
                  new MyRoute("reports/{page}", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Reports", action = "Index", page = 1 })
            }
                  );

            c.Add("Default",
                  new MyRoute("{controller}/{action}", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index" })
            }
                  );

            var hc = new HttpContextStub2("~/Home/About", String.Empty, String.Empty);

            hc.SetResponse(new HttpResponseStub(2));
            var rd  = c.GetRouteData(hc);
            var vpd = c.GetVirtualPath(new RequestContext(hc, rd), rd.Values);

            Assert.IsNotNull(vpd, "#A1");
            Assert.AreEqual("/Home/About_modified", vpd.VirtualPath, "#A2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#A3");

            hc = new HttpContextStub2("~/Home/Index", String.Empty, String.Empty);
            hc.SetResponse(new HttpResponseStub(2));
            rd  = c.GetRouteData(hc);
            vpd = c.GetVirtualPath(new RequestContext(hc, rd), rd.Values);
            Assert.IsNotNull(vpd, "#B1");
            Assert.AreEqual("/_modified", vpd.VirtualPath, "#B2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#B3");

            hc = new HttpContextStub2("~/Account/LogOn", String.Empty, String.Empty);
            hc.SetResponse(new HttpResponseStub(2));
            rd  = c.GetRouteData(hc);
            vpd = c.GetVirtualPath(new RequestContext(hc, rd), rd.Values);
            Assert.IsNotNull(vpd, "#C1");
            Assert.AreEqual("/Account/LogOn_modified", vpd.VirtualPath, "#C2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#C3");

            hc = new HttpContextStub2("~/", String.Empty, String.Empty);
            hc.SetResponse(new HttpResponseStub(3));
            rd  = c.GetRouteData(hc);
            vpd = c.GetVirtualPath(new RequestContext(hc, rd), new RouteValueDictionary(new { controller = "home" }));
            Assert.IsNotNull(vpd, "#D1");
            Assert.AreEqual("/", vpd.VirtualPath, "#D2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#D3");

            hc = new HttpContextStub2("~/", String.Empty, String.Empty);
            hc.SetResponse(new HttpResponseStub(3));
            rd  = c.GetRouteData(hc);
            vpd = c.GetVirtualPath(new RequestContext(hc, rd), new RouteValueDictionary(new { controller = "Home" }));
            Assert.IsNotNull(vpd, "#E1");
            Assert.AreEqual("/", vpd.VirtualPath, "#E2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#E3");
        }
Exemplo n.º 60
0
        public void GetVirtualPath8()
        {
            var routes = new RouteCollection();

            routes.Add(new MyRoute("login", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Home", action = "LogOn" })
            });

            routes.Add(new MyRoute("{site}/{controller}/{action}", new MyRouteHandler())
            {
                Defaults    = new RouteValueDictionary(new { site = "_", controller = "Home", action = "Index" }),
                Constraints = new RouteValueDictionary(new { site = "_?[0-9A-Za-z-]*" })
            });

            routes.Add(new MyRoute("{*path}", new MyRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Error", action = "NotFound" }),
            });

            var hc = new HttpContextStub2("~/login", String.Empty, String.Empty);

            hc.SetResponse(new HttpResponseStub(3));
            var rd  = routes.GetRouteData(hc);
            var rvs = new RouteValueDictionary()
            {
                { "controller", "Home" },
                { "action", "Index" }
            };
            var vpd = routes.GetVirtualPath(new RequestContext(hc, rd), rvs);

            Assert.IsNotNull(vpd, "#A1");
            Assert.AreEqual("/", vpd.VirtualPath, "#A2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#A3");

            hc = new HttpContextStub2("~/login", String.Empty, String.Empty);
            hc.SetResponse(new HttpResponseStub(3));
            rd  = routes.GetRouteData(hc);
            rvs = new RouteValueDictionary()
            {
                { "controller", "Home" }
            };
            vpd = routes.GetVirtualPath(new RequestContext(hc, rd), rvs);
            Assert.IsNotNull(vpd, "#B1");
            Assert.AreEqual("/login", vpd.VirtualPath, "#B2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#B3");

            hc = new HttpContextStub2("~/login", String.Empty, String.Empty);
            hc.SetResponse(new HttpResponseStub(3));
            rd  = routes.GetRouteData(hc);
            rvs = new RouteValueDictionary()
            {
                { "action", "Index" }
            };
            vpd = routes.GetVirtualPath(new RequestContext(hc, rd), rvs);
            Assert.IsNotNull(vpd, "#C1");
            Assert.AreEqual("/", vpd.VirtualPath, "#C2");
            Assert.AreEqual(0, vpd.DataTokens.Count, "#C3");

            hc = new HttpContextStub2("~/", String.Empty, String.Empty);
            rd = routes.GetRouteData(hc);
            Assert.IsNotNull(rd, "#D1");
        }