'~/Areas/SomeArea/Views/List/Index.cshtml' のビューは、ViewPage、ViewPage、ViewUserControl、または ViewUserControl から派生する必要があります。
プロジェクト構造はほとんどデフォルトです。SomeArea と呼ばれるエリアが 1 つあります。List と呼ばれる単一のコントローラーがあります。それ以外は何もしません:
public ActionResult Index()
{
return View("~/Areas/SomeArea/Views/List/Index.cshtml");
}
ビューは次のようになります。
@inherits System.Web.Mvc.WebViewPage<dynamic>
@{
View.Title = "Index";
LayoutPage = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
ファイル全体を部分的に空にしようとしましたが、何も役に立たないようです。コントローラーを作成して領域外に表示すると、問題なく動作します。デフォルトのカミソリ ビュー エンジンが現時点で領域をサポートしていない可能性はありますか?
編集: エリアが登録されます。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Random", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"SomeArea_default",
"SomeArea/{controller}/{action}/{id}",
new { controller = "List", action = "Index", id = UrlParameter.Optional }
);
}