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


C# RouteCollection.MapRoute方法代码示例

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


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

示例1: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapMvcAttributeRoutes();

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

            // 1 - Home

            routes.MapRoute(null, "", new { controller = "Vitrine", action = "ListaProdutos", categoria = (string)null, pagina = 1 });

            // 2 -
            routes.MapRoute(null,
                "Pagina{pagina}",
                new { controller = "Vitrine", action = "ListaProdutos", categoria = (string)null }, new { pagina = @"\d+" });

            routes.MapRoute(null,
                "{categoria}", new { controller = "Vitrine", action = "ListaProdutos", pagina = 1 });

            routes.MapRoute(null,
                "{categoria}/Pagina{pagina}", new { controller = "Vitrine", action = "ListaProdutos" }, new { pagina = @"\d+" });

            //routes.MapRoute(
            //    "ObterImagem",
            //    "Vitrine/ObterImagem/{produtoId}",
            //    new {controller = "Vitrine", action = "ObterImagem", produtoId = UrlParameter.Optional});

            routes.MapRoute(null, "{controller}/{action}");
        }
开发者ID:pauloDevrecife,项目名称:MVC_Loja,代码行数:28,代码来源:RouteConfig.cs

示例2: RegisterSpecialRoutes

		private static void RegisterSpecialRoutes(RouteCollection routes)
		{
			// /Wiki/Special:{id} urls
			routes.MapRoute(
				"SpecialPages",
				"Wiki/Special:{id}",
				new { controller = "SpecialPages", action = "Index" }
			);

			// /Wiki/Help:About
			routes.MapRoute(
				"Help:About",
				"Wiki/Help:About",
				new { controller = "Help", action = "About" },
				null,
				new string[] { "Roadkill.Core.Mvc.Controllers" }
			);

			// /Wiki/Help:Cheatsheet
			routes.MapRoute(
				"Help:CheatSheet",
				"Wiki/Help:Cheatsheet",
				new { controller = "Help", action = "Index" },
				null,
				new string[] { "Roadkill.Core.Mvc.Controllers" }
			);
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:27,代码来源:Routing.cs

示例3: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "ApiSearch",                                           // Route name
                "artist/search/{search_criteria}/{page_number}/{page_size}",                            // URL with parameters
                new { controller = "Api", action = "Search", page_number = UrlParameter.Optional, page_size = UrlParameter.Optional }  // Parameter defaults
            );

               // /artist/6c44e9c22-ef82-4a77-9bcd-af6c958446d6/albums
            routes.MapRoute(
                "GetTopAlbums",                                           // Route name
                "artist/{artist_id}/albums",                            // URL with parameters
                new { controller = "Api", action = "GetTopAlbums" }  // Parameter defaults
            );

            // /artist/6c44e9c22-ef82-4a77-9bcd-af6c958446d6/albums
            routes.MapRoute(
                "GetReleases",                                           // Route name
                "artist/{artist_id}/releases",                            // URL with parameters
                new { controller = "Api", action = "GetReleases" }  // Parameter defaults
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
开发者ID:cvizzini,项目名称:backend-developer-assessment,代码行数:30,代码来源:RouteConfig.cs

示例4: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "file_upload",
                url: "file/upload/{file}",
                defaults: new { controller = "Blog", action = "FileUpload", file = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "manage_blog",
                url: "manage/blog/{action}/{id}",
                defaults: new { controller = "Blog", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "manage_product",
                url: "manage/product/{action}/{id}",
                defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional }
            );

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

            routes.MapRoute(
                name: "default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Home", id = UrlParameter.Optional }
            );
        }
开发者ID:JJarczyk12,项目名称:Price-Point,代码行数:34,代码来源:RouteConfig.cs

示例5: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("Plugins", "plugins/{action}", new { controller = "Plugins" });
            routes.MapRoute("BackboneDirectAccess", "{*url}", new { controller = "Home", action = "Index" });
        }
开发者ID:benjaminramey,项目名称:GoodlyFere.Import.Web,代码行数:7,代码来源:RouteConfig.cs

示例6: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            /*rutarea catre incarcarea de fisier*/
            routes.MapRoute(
                "Upload", // Route name
                "Up", // URL with parameters
                new { controller = "Load", action = "Upload" }
            );

            /*rutarea catre incarcarea unui document deja existent*/
            routes.MapRoute(
                "Load", // Route name
                "Load/{id}", // URL with parameters
                new { controller = "Load", action = "Load", id = UrlParameter.Optional}
            );

            /*rutarea catre controllerul principal*/
            routes.MapRoute(
                "Home", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

            /*rutarea catre controllerul de cereri XML*/
            routes.MapRoute(
                "Get", // Route name
                "{controller}/{action}/{id}/{question}", // URL with parameters
                new { controller = "Get", action = "Summary", id = UrlParameter.Optional, question = UrlParameter.Optional }
            );
        }
开发者ID:colin-dumitru,项目名称:Proiect-AI-2012---GUI,代码行数:32,代码来源:Global.asax.cs

示例7: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Create",
            //    url: "Tool/Create",
            //    defaults: new { controller = "Tool", action = "Create" }
            //);

            // This route creates a short URL to a specific tool.
            // this makes it easy to copy and paste.
            // For example, http://localhost/Tool/5
            routes.MapRoute(
                name: "Launch",
                url: "Tool/{id}", 
                defaults: new { controller = "Tool", action = "View" },
                constraints: new { id = @"\d+" }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
开发者ID:tebass,项目名称:LtiSamples,代码行数:26,代码来源:RouteConfig.cs

示例8: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Match empty URL (~/)
            routes.MapRoute(
                null,
                string.Empty,
                new
                {
                    controller = "Bookmarks",
                    action = "List",
                    page = 1
                }
            );

            // Match new
            routes.MapRoute(
               null,
               "New",
               new
               {
                   controller = "Bookmarks",
                   action = "New",
                   page = 1
               }
               );

            // Map numeric pages ~/Page123, ~/Page2
            routes.MapRoute(
                null,
                "Page{page}",
                new
                {
                    controller = "Bookmarks",
                    action = "List"
                },
                new
                {
                    page = @"\d+"
                }
            );

            // Match Admin
            routes.MapRoute(
                null,
                "Bookmarks/{controller}/{action}",
                new
                {
                    controller = "Bookmarks",
                    action = "List",
                    page = 1
                }
            );

            routes.MapRoute(
               null,
               "{controller}/{action}"
               );
        }
开发者ID:scottmetoyer,项目名称:bookmarks,代码行数:60,代码来源:Global.asax.cs

示例9: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            AreaRegistration.RegisterAllAreas();

            routes.MapRoute(
                name: "Board",
                url: "",
                defaults: new { controller = "Home", action = "Board" }
            );

            routes.MapRoute(
                name: "Vote",
                url: "vote",
                defaults: new { controller = "Home", action = "Index" }
            );

            routes.MapRoute(
                name: "Login",
                url: "login",
                defaults: new { controller = "Account", action = "Login" }
            );

            routes.MapRoute(
                name: "Registration",
                url: "registration",
                defaults: new { controller = "Account", action = "Register" }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}",
                defaults: new { controller = "Home", action = "Index" }
            );
        }
开发者ID:san4oz,项目名称:AskGenerator,代码行数:35,代码来源:RouteConfig.cs

示例10: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    "Default", // Route name
            //    "{controller}/{action}", // URL with parameters
            //    new { controller = "Tasks", action = "Index"} // Parameter defaults
            //    );

            routes.MapRoute("About", "{controller}/{action}", new { controller = "Tasks", action = "About" });

            routes.MapRoute(
                "Tasks", "{controller}/{action}/{project}", new { controller = "Tasks", action = "TaskList" });

            routes.MapRoute(
                "ImageRoute",
                "{controller}/{action}/{id}",
                new { controller = "Tasks", action = "Images" });

            routes.MapRoute(
                "ClearServerCache", "{controller}/{action}", new { controller = "Tasks", action = "ClearServerCache" });

            routes.MapRoute(
                "ImportData",
                "{controller}/{action}/{project}",
                new { controller = "Tasks", action = "ImportData" });
        }
开发者ID:issafram,项目名称:TeamDashboardKanban,代码行数:28,代码来源:Global.asax.cs

示例11: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
              name: "ListTopRoute",
              url: "ListTop/{page}",
              defaults: new { controller = "Page", action = "ListTopPages", page = UrlParameter.Optional }
          );

            routes.MapRoute(
              name: "ListRoute",
              url: "List/{category}/{idCategory}/{page}",
              defaults: new { controller = "Page", action = "List", category = UrlParameter.Optional, idCategory = UrlParameter.Optional, page = UrlParameter.Optional }
          );

            routes.MapRoute(
              name: "ArchiveRoute",
              url: "Archive/{page}/{id}",
              defaults: new { controller = "Page", action = "Index", page = UrlParameter.Optional, id = UrlParameter.Optional }
          );

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

          
        }
开发者ID:raowyr,项目名称:BlogProject,代码行数:30,代码来源:RouteConfig.cs

示例12: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            routes.MapRoute("cache.manifest", "cache.manifest", new { controller = "Resources", action = "Manifest" });

            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            routes.MapRoute(
                name: "Readability",
                url: "{controller}/{action}/{url}",
                defaults: new { controller = "Readability", action = "Index" }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
开发者ID:alexbeletsky,项目名称:aspnet.mobile,代码行数:25,代码来源:Global.asax.cs

示例13: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "qualified",
                url: "{realm}/{faction}/{controller}/{action}/{id}",
                defaults: new
                {
                    id = UrlParameter.Optional,
                    realm = UrlParameter.Optional,
                    faction = UrlParameter.Optional
                }
            );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new
                {
                    controller = "Home",
                    action = "Index",
                    id = UrlParameter.Optional
                }
            );
        }
开发者ID:TheRealSplith,项目名称:WoWEcon,代码行数:25,代码来源:RouteConfig.cs

示例14: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Poll",
                url: "{shortUrl}",
                defaults: new { controller = "Home", action = "Poll" }

                );

            routes.MapRoute(
                name: "PollResults",
                url: "PollResults/{shortUrl}",
                defaults: new { controller = "Home", action = "PollResults" }

                );

            routes.MapRoute(
                name: "AdminPoll",
                url: "AdminPoll/{password}",
                defaults: new { controller = "Home", action = "AdminPoll" }

                );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
开发者ID:mrhaseebmohammed,项目名称:TallyV2,代码行数:31,代码来源:RouteConfig.cs

示例15: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Search",
                url: "Search/{type}/{attribute}",
                defaults: new { controller = "Search", action = "Attribute", type = "all", attribute = "all" }
                );

            routes.MapRoute(
                name: "Collection",
                url: "Collection",
                defaults: new { controller = "Collection", action = "Index" }
            );

            routes.MapRoute(
                          name: "Collection_Category",
                          url: "Collection/{category}",
                          defaults: new { controller = "Collection", action = "Category", category = UrlParameter.Optional }
                      );

            routes.MapRoute(
                name: "Collection_Category_Product",
                url: "Collection/{category}/{product}",
                defaults: new { controller = "Collection", action = "Product", category = UrlParameter.Optional, product = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
开发者ID:Narelle,项目名称:AffiliateBasicSite,代码行数:34,代码来源:RouteConfig.cs


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