MVC3 アプリケーションを 2 つの領域に分割する作業を行っています。既存のアプリケーションは 1 つの領域 (V1) に入り、2 つ目の領域 (V2) で再設計を開始しています。
Views、Models、Controllers などをすべて MyApp\Areas\V1\xxx フォルダーに移動しました。ほとんどの場合、必要に応じてロードされていることを確認できました。V1 のすべての Route 登録を V1AreaRegistration.cs ファイルに移動し、context.MapRoute
代わりに使用するように変更しましたRouteTable.Routes.MapRoute
。
Phil Haack の RouteDebugger を使用してルーティングを確認すると、すべて問題ないように見えます。V2 ルートは適切に解決されており、基本的な V1 ルートは機能しています。MvcRouteHandler
機能していないのは、次のようなカスタム定義がある V1 ルートです。
context.MapRoute(
"MyRouteName",
"{myRouteVal}/{controller}/{action}",
new { area = "V1", controller = "DefaultController", action = "Index" },
new { controller = _someRouteConstraint},
new string[] { "My.Custom.Project.WebLibrary.Areas.V1.Controllers" },
_myCustomRouteHandler);
この呼び出しからを削除すると、正常に機能_myCustomRouteHandler
し、V1 エリアの下の正しいビューに移動します。配置すると、ルーティングはそれがエリア ルートとして登録されているという事実を無視しているように見え、次のような黄色のエラー ページが表示されます。
The view 'Index' or its master was not found or no view engine
supports the searched locations. The following locations were searched:
~/Views/DefaultController/Index.cshtml
~/Views/DefaultController/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
~/Views/DefaultController/Index.aspx
~/Views/DefaultController/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
ルート ハンドラーを使用できるようにする必要があり{myRoutVal}
ます。パラメーターに対していくつかの検証作業を行い、無効な場合はエラー ページにリダイレクトします。
ヘルプ!!