我有一個MVC 4的網站幾個方面......使用I'm由VS2012創建的所有默認路由裏面......MVC 4路由「發現」控制器的區域
所以,我可以訪問(從區域1 ):
Area1/ControllerX/ActionX
我有沒有一些區域控制器,這樣我就可以訪問:
ControllerY/ActionY
一切都很好......但是,如果我嘗試訪問ControllerX無區域1,這樣的:
ControllerX/ActionX
我得到的錯誤:
Exception: The view 'ActionX' or its master was not found or no view engine supports the
searched locations. The following locations were searched: ~/Views/mangavagao/ActionX.cshtml
~/Views/Shared/ActionX.cshtml
Controller: ControllerX
Action: ActionX
我期待一個未找到404錯誤...爲什麼這條路線被抓獲?
-
地區航線:
context.MapRoute(
"Area1_default",
"Area1/{controller}/{action}/{id}",
new { controller = "ControllerX", action = "ActionY", id = UrlParameter.Optional }
);
默認路由:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "ControllerY", action = "ActionY", id = UrlParameter.Optional );
因此'ControllerX'駐留在'Area1'中,但'ControllerY'只是一個標準控制器,對嗎? –
是的,ControllerY沒有區域。 – Paul