当前位置: 首页>>代码示例>>C#>>正文


C# RouteCollection.Add方法代码示例

本文整理汇总了C#中RouteCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.Add方法的具体用法?C# RouteCollection.Add怎么用?C# RouteCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RouteCollection的用法示例。


在下文中一共展示了RouteCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterRoutes

        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"
            });
        }
开发者ID:Gluba,项目名称:SportsStore,代码行数:25,代码来源:RouteConfig.cs

示例2: RegisterRoutes

        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 }
            //);
        }
开发者ID:khhily,项目名称:Lean,代码行数:33,代码来源:RouteConfig.cs

示例3: RegisterRoutes

        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
            );
        }
开发者ID:JSkimming,项目名称:Subdomain-Routing,代码行数:34,代码来源:Global.asax.cs

示例4: GetFormHelper

        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;
        }
开发者ID:davidalmas,项目名称:Samples,代码行数:31,代码来源:FormExtensionsTest.cs

示例5: RegisterRoutes

        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
            );
        }
开发者ID:overeemm,项目名称:yawamt,代码行数:32,代码来源:Global.asax.cs

示例6: RegisterRoutes

        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" });
        }
开发者ID:akhuang,项目名称:Books-SourceCode,代码行数:34,代码来源:Global.asax.cs

示例7: RegisterRoutes

        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
            );
        }
开发者ID:ericmbarnard,项目名称:RESTPerf,代码行数:26,代码来源:Global.asax.cs

示例8: AddNullMame

		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));
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:RouteCollectionTest.cs

示例9: RegisterModelRoutes

        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
                });
            }
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:27,代码来源:Global.asax.cs

示例10: GetFormHelper

        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;
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:28,代码来源:FormExtensionsTest.cs

示例11: RegisterRoutes

        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 }
            //);
        }
开发者ID:Defcoq,项目名称:YogamHealth,代码行数:31,代码来源:RouteConfig.cs

示例12: RegisterRoutes

        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())));
        }
开发者ID:szp11,项目名称:nina,代码行数:7,代码来源:Global.asax.cs

示例13: RegisterRoutes

        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()));
        }
开发者ID:jaime-lee,项目名称:DocumentServer,代码行数:7,代码来源:Global.asax.cs

示例14: RegisterRoutes

        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
            );*/
        }
开发者ID:Throy,项目名称:derp-octo-robot,代码行数:29,代码来源:Global.asax.cs

示例15: AddDuplicateEmpty

		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));
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:RouteCollectionTest.cs


注:本文中的RouteCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。