0
奇怪爲什麼在默認的MVC路由導致UrlHelper.GenerateUrl出現問題之前聲明MapPageRoute。爲什麼混合MVC和webforms時路由映射的順序很重要?
我開始與這在我的Global.asax.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("MyApp", "home/my-app", new { controller = "Home", action = "MyApp" });
routes.MapPageRoute("MyOldWebForm", "oldform.aspx", "~/WebForms/OldForm.aspx");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Site", action = "Index", id = UrlParameter.Optional });
}
在視圖中默認的聲明像@Html.BeginForm()
,或控制器調用結果像RedirectToAction("Index", "Errors", new {fault = "itemMissing"});
將產生的URL「的任何引用oldform.aspx 」。
當我使用頁面路由交換默認MVC路由的順序時,它按預期工作。
權,應用程序是MVC和一些舊的Web表單的混合。 – 2011-04-12 18:18:36
你是否想解決問題? – Nario 2011-04-12 18:27:41