相信我,您不想弄乱默认路由,这会让您头疼,您可以保留默认路由,并创建一个辅助路由,例如:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"SEORoute1", // Route name
"{company}/{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
当您需要使用路线时,只需使用此助手:
@Html.RouteLink("LinkText","SEORoute1",new { action = "Index", controller = "Home", company = item.Name, id = item.Code })