earlxtr
earlxtr

Reputation: 370

RenderAction in Layout causing ActionLinks to Error

I have a Partial View that has an ActionLink in the view

@Html.ActionLink("User Admin Controller", "Index", "UserAdmin", new { Area = "Security" }, new { })

When I put an RenderAction Helper on a page view to render the partial view, the ActionLink works fine

@{Html.RenderAction("ApplicationMenu", "Layout"); }

However, when I put the Render Action Helper into the Layout View, then clicking on the action link in either the page view or the layout causes an error message

The controller for path '/Security/UserAdmin' was not found or does not implement IController.

It seems that the fact that the target page is calling the same RenderAction helper is causing a problem???

Thank you for your help

Earl

Upvotes: 0

Views: 465

Answers (2)

earlxtr
earlxtr

Reputation: 370

I believe that this was related directly to routing. I had the home controller outside of my areas and everything else in areas. When I created a common area and moved the home controller into it, everything worked. I probably could have solved this by modifying the routing table but this got the job done.

Upvotes: 1

Ali Soltani
Ali Soltani

Reputation: 9927

Edit ActionLink like this:

@Html.ActionLink("User Admin Controller", "Index", "UserAdmin", new { Area = "" }, new { })

When using Areas, you should always specify the area your are calling in your ActionLinks by adding a route value as above, If the link is outside the area (as in your case), just use an empty parameter for the area.

Upvotes: 0

Related Questions