开发者

How to render a partial in the main project from an area in MVC 3?

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, whe开发者_Go百科n 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!


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 }); }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜