2

I have a MVC 3 Razor project. It has an area called Admin. I have the basic layout of the page in the project's Views/Shared folder (by default). I have a controller in the main project called Common. It will be in charge of certain parts of the layout that are based on business logic (navigation based upon roles, etc.). I have

@Html.Action("Navigation", "Common")

being called in the _layout.cshtml file. That is set to render the nav bar. When I go to a route in the Admin area ("admin/somedomainobject/add"), a run time error states the following:

"The controller for path "/admin/somedomainobject/add" was not found or does not implement IController."

It exists just fine, when I remove the line from the layout. The error is happening if I use the above syntax or the following:

@{Html.RenderAction("Naviation", "Common");}

Is it because I am using areas? Am I utilizing the main project folders the wrong way?

Any ideas would be greatly appreciated!

Dan Appleyard
  • 7,405
  • 14
  • 49
  • 80

1 Answers1

7

It is because in your admin area all generated links will inherit this area unless explicitly told otherwise, try

@{ Html.RenderAction("Naviation", "Common", new { @area = string.Empty }); }
Lukáš Novotný
  • 9,012
  • 3
  • 38
  • 46