更新时间:2023-11-27 18:49:28
它如果添加上述通用的那些哈日codeD路线是可行的轻松:
It's easily feasible if you add the harcoded routes above the generic ones:
// AboutController.Index()
routes.MapRoute(
"About",
"about",
new { controller = "About", action = "Index" });
// HomeController.Index()
routes.MapRoute(
"Home",
"home",
new { controller = "Home", action = "Index" });
// ArticleController.Index(string category, string pagename)
routes.MapRoute(
"Article",
"{category}/{pagename}",
new { controller = "Article", action = "Index" });
他们可能都使用相同的控制器,如果你想要,但如果他们使用独立的人可能更容易一点。
They could all use the same controller if you wanted, but it might be a bit easier if they used separate ones.
您将有唯一的问题是,如果你有一个名为约或家范畴,但这种情况不太可能我会想象。
The only problem you would have with this is if you had a category called "about" or "home" but this is unlikely I would imagine.
还应当指出的是不必使用ASP.NET MVC使用路由能力。