这就是我能够实现我认为你的要求的方式。
// Portal Sections
routes.MapRoute("Home",
"",
new { controller = "Home", action = "Index" },
new[] { "Myapp.Portal.Controllers" });
routes.MapRoute("About",
"about",
new { controller = "Home", action = "About" },
new[] { "Myapp.Portal.Controllers" });
routes.MapRoute("Features",
"features",
new { controller = "Home", action = "Features" },
new[] { "Myapp.Portal.Controllers" });
routes.MapRoute("Help",
"help",
new { controller = "Help", action = "Index" },
new[] { "Myapp.Portal.Controllers" });
routes.MapRoute("Knowledgebase",
"help/kb",
new { controller = "Help", action = "Knowledgebase" },
new[] { "Myapp.Portal.Controllers" });
我可以访问
- mysite.com
- mysite.com/about
- mysite.com/features
- mysite.com/help
- mysite.com/help/kb
但无法访问
- mysite.com/home/about
- mysite.com/home/features
希望这有帮助:)