私のMVC 5アプリケーションに2つの領域があり、正しく動作しません。MVC5領域が機能しない
私は、以下のリンクhttp://localhost:45970/Admin/Admin
を使用するとアプリが、私はそれが/Views/Admin/Index.cshtml
からIndex.cshtmlファイルをロードしようとhttp://localhost:45970/Admin
ロードしようとすると、しかし/Areas/Admin/Views/Admin/Index.cshtml
に位置していますwhicxh適切index.cshtmlをロードします。
すべての検索結果は、私が正しいことをしていると言います。私は、APIのサンプルプロジェクトを読み込んで、ヘルプエリアを見て、正しく機能していることを確認しました。ここで
は私RouteConfig.csがここ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace BlocqueStore_Web
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "BlocqueStore_Web.Controllers" }
);
}
}
}
ファイルである私のGlobal.asax.csののApplication_Start()セクションが
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
そして最後に、私のAdminAreaRegistrationファイルです。 CSファイル
using System.Web.Mvc;
namespace BlocqueStore_Web.Areas.Admin
{
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "BlocqueStore_Web.Areas.Admin.Controllers" }
);
}
}
}
だから私は何が欠けていますか?
の
defaults
パラメータでIndex
へAdmin
にコントローラとアクションを設定:// localhostを:45970/Admin'を? – ekadデフォルトでは、/Areas/Admin/Views/Admin/Index.cshtmlをロードする必要があります。 –
は、返されたキーを修正したコメントが –