【发布时间】:2012-01-09 07:02:27
【问题描述】:
我有 global.ascx 和三个路由
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"TestRoute",
"{id}",
new { controller = "Product", action = "Index3", id = UrlParameter.Optional },
new { id = @"\d+" } //one or more digits only, no alphabetical characters
);
routes.MapRoute(
"TestCatalogRoute",
"{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "RsvpForm", id = UrlParameter.Optional } // Parameter defaults
//new { controller = "Product", action = "Index2", id = UrlParameter.Optional } // Parameter defaults
);
}
当我输入网址时:
http://mydomain.com/
它使用“TestCatalogRoute”路由,但我想要“默认”路由 T.T
如何:
- 带有网址:
http://mydomain.com它使用“默认”路由 - 带有 url:
http://mydomain.com/1它使用“TestRoute”路由(已经完成!) - 带有 url:
http://mydomain.com/abc它使用“TestCatalogRoute”路由
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 razor asp.net-mvc-routing