剛剛創建了一個新的MVC 4項目,並從MVC 3項目中複製了一些區域。我已經加倍檢查了我的所有web.configs和arearegistration.cs。我CONFIGS都指向剃刀和MVC和我routes.MapRoute簽名的正確版本包括正確的命名空間參數,我還檢查並確保我的IIS池未託管不止一個MVC應用程序。ASP.Net MVC 4 - 發現多個類型與名爲'Home'的控制器相匹配。
context.MapRoute(
"Terminator_default",
"Terminator/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "MVCProject.Web.Areas.Terminator.Controllers" }
);
我檢查我知道的一切
我的Global.asax文件...
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "MVCProject.Web.Controllers" }
);
我區註冊文件...
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "MVCProject.Web.Areas.Admin.Controllers" }
);
和...檢查來解決這個 ,正確的DLL的加載區以及...
你使用自定義的依賴性/控制器解析器?當您實施自定義解析器(即Windsor)並使用區域時,還需要特別小心。也看到了這個問題:http://stackoverflow.com/questions/5092589/having-issue-with-multiple-controllers-of-the-same-name-in-my-project – 2012-02-24 01:27:58
是我使用StructureMap – JBeckton 2012-02-24 01:34:09
的可能重複[找到了多個類型匹配命名爲「家」的控制器(http://stackoverflow.com/questions/7842293/multiple-types-were-found-that-match-the-controller-named-home) – bummi 2013-09-24 11:21:40