我创建了一个页面的路线,所以我可以与存在于我的项目数的WebForms页我的MVC应用程序集成:MVC的MapPageRoute和ActionLink的
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// register the report routes
routes.MapPageRoute("ReportTest",
"reports/test",
"~/WebForms/Test.aspx"
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
这就造成一个问题,每当我在使用Html.ActionLink我的看法:
<%: Html.ActionLink("Home", "Index", "Home") %>
当我在链接出现像浏览器加载页面:
http://localhost:12345/reports/test?action=Index&controller=Home
有没有人遇到过这个?我怎样才能解决这个问题?
谢谢。我想避免使用RouteLink只是为了简洁,但我可能不得不使用它。我只是不明白为什么当我使用ActionLink时页面路线与我的常规路线相匹配。 – Dismissile 2010-12-15 15:33:29