我將默認路由對象設置爲區域(也稱爲「Beheer」)內的控制器(「Beheer」)。MVC3到區域的默認路徑不搜索區域內的視圖
像這樣:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Beheer", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
可以發現,控制和區域內的動作很好,但它無法找到視圖,因爲它只是看起來在這些位置:
~/Views/Beheer/Index.aspx
~/Views/Beheer/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Beheer/Index.cshtml
~/Views/Beheer/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
雖然它應該看在這個位置:
~/Beheer/Views/Beheer/Index.aspx
我該如何使它搜索視圖th ERE?
我已經嘗試過:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { area = "Beheer", controller = "Beheer", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
我想這(與命名空間):
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Beheer", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new[] { "Areas.Beheer" }
);
但是沒有什麼變化。它在正確的控制器中輸入正確的操作,但找不到視圖。
這已經出現在BeheerAreaRegistration中。我應該改變這裏的東西嗎? – David 2011-12-15 13:45:09