【发布时间】:2011-11-11 15:29:06
【问题描述】:
我在全局 asax 中有两个 MapRoute。`
routes.MapRoute(
"AutoGeneratedURLHandler", // Route name
"{modulepath}/{controller}/{action}/{id}", // URL with parameters
new { id = UrlParameter.Optional } // Parameter defaults
);
//default route
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "Logon", id = UrlParameter.Optional } // Parameter defaults
);`
我在母版页上有两个链接。
<li><%:Html.ActionLink("Card Types", "Index", "CardType", new { modulepath="CardManagement" },null)%></li>
<li><%:Html.ActionLink("Home Page", "Index", "Home")%></li>
点击卡片类型链接后,主页链接变为“/CardManagement/Home/Index”而不是“/Home/Index”。
路由值记住“modulepath”并将其自动添加到主页链接。但我不想要这个。如何让它不向 url 添加模块路径?
【问题讨论】:
-
当我使用
Html.RouteLink和RedirectToRoute而不是Html.ActionLink和RedirectToAction时,它按预期工作。但是没有其他解决方案吗?我不应该在项目中使用Html.ActionLink和RedirectToAction吗?
标签: asp.net asp.net-mvc-3 routes