我创建了一个页面路由,因此我可以将我的MVC应用程序与我项目中存在的一些WebForms页面集成:
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 }
);
}
Run Code Online (Sandbox Code Playgroud)
每当我在视图中使用Html.ActionLink时,这就产生了一个问题:
<%: Html.ActionLink("Home", "Index", "Home") %>
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中加载页面时,链接显示如下:
http://localhost:12345/reports/test?action=Index&controller=Home
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过这个?我怎样才能解决这个问题?