我創建了一個頁面的路線,所以我可以與存在於我的項目數的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