我在MVC中創建了一個區域,然後我創建了一個簡單的控制器,我無法查看該區域或我網站的該部分中的任何頁面是否有人知道爲什麼以及如何解決此問題。我用Area創建了一個項目,並且沒有問題,我不知道發生了什麼變化,或者如果我必須改變某些內容才能使其工作,有人可以幫我解決問題。區域中找不到資源
某處它沒有被註冊。
namespace RedPlanet.Areas.admin.Controllers
{
public class CategoryController : Controller
{
}
}
地區:
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 }
);
}
}
全球ASAX:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
System.Data.Entity.Database.SetInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges<DataContext>());
}
}
顯示控制器代碼(包括命名空間) – Igor
這可能幫助你[http://stackoverflow.com/questions/15616240/mvc-area-routing](http://stackoverflow.com/questions/15616240/ mvc-area-routing) –
你的控制器有任何操作嗎?您也不要在您的區域路線中定義默認控制器。 – GvM