I have an MVC4 project with language selection:
- en
- nl
- fr
- de
1 main part with:
- About
- Common (for the menu)
- Contact
- Faq
- Home
And 3 areas:
- Admin
- Customers
- Shop
In each area I have at least one controller, for example in Admin I have the controller overview with the corresponding view folder overview which contains an index.aspx page.
The home page and all the main pages (about, faq, etc.) work and can be visited).
However, when I follow the url: localhost:xxxx/en/admin/overview I get the error
The controller for path '/en/admin/overview' was not found or does not implement IController.
Even though, the route is correct (I can see this with Route Debugger). THe error page also shows that the error was thrown when I wanted to load my main menu items:
<nav id="site-navigation" class="eightcol">
@Html.Action("MenuItems", "Common")
</nav>
-- Code removed because irrelevant --
Everything seems to be in order, but MVC doesn't seem to be able to load the menu, which is located in the main part.
So, the root of the problem is: Can I grant an area (e.g. Admin) access to the controllers in the main part (home, common, about, etc.) of my project?
In another scenario just I would like to add is In my scenario, the name space was different for controller as it was mistake of copying controller from another project.
Also, for those who the solution above didn't work, here's is what worked for me:
I have a solution with multiple projects. All projects were in MVC3. I installed Visual Studio 2012 in my machine and it seems that some projects were automatically upgraded to MVC4.
I got this problem
because the project that handled that route was pointing to MVC4.
I had to manually update their references to use MVC3. You can also do that by opening the .csproj file with a text editor. Find the reference to MVC3 and remove this line:
in my case, the problem was that the controller class has not been publicly announced.
the solution was
This error can also be caused by the fact that Controllers must have (in their name) the word
Controller
; viz:HomeController
; unless you implement your ownControllerFactory
.In my case I had
@{ Html.RenderAction("HeaderMenu", "Layout", new { Area = string.Empty }); }
in _Layout.cshtml but the LayoutController did not exist! (I had copied _Layout.cshtml from another solution but forgot to copy the controller)In my case of legacy application, the issue occurred when I added below entry in web.config file under the node
<system.webServer>
When I removed it, the issue resolved.