Reputation: 7111
Just created a new MVC 4 project and copied over some areas from an MVC 3 project. I have double checked all my web.configs and arearegistration.cs. My configs all point to the correct versions of razor and MVC and my routes.MapRoute signature includes the correct namespace parameters, I also checked and made sure my IIS pool was not hosting more than one MVC app.
my Global.asax file...
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" }
);
my area registration files...
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "MVCProject.Web.Areas.Admin.Controllers" }
);
and ...
context.MapRoute(
"Terminator_default",
"Terminator/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "MVCProject.Web.Areas.Terminator.Controllers" }
);
I have checked everything I know to check to fix this , the correct dll's area loaded as well...
Upvotes: 3
Views: 4702
Reputation: 957
Another plausible cause of this issue could be found below:
multiple-types-were-found-that-match-the-controller-named-home
Upvotes: 0
Reputation: 7111
Ok I figured out what was going on. I'll answer my own question in hopes that it helps someone else.
Typically when you create a new MVC project in VS 2010 you get what the template gives you as far as name spaces and a stubbed out home controller or two. I like to break my MVC app up into the usual layers (Data, Model & Service) with each layer being in it's own project. Then I rename my web project to append .web to the project name and name space "MyWebProject.Web".
The template created the app prior to me renaming the web project and stubbed out a home controller for me. The home controller created by the template was in the MyWebProject.Controllers namespace, my routes.MapRoutes() used MyWebProject.Web.Controllers as a parameter.
Once I moved my stubbed out controllers created by the template into the MyWebProject.Web.Controllers namespace it fixed the problem.
Upvotes: 1