views:

478

answers:

2

I have a shared master page which I am using from 2 different areas in my mvc 2 app. The master page has an action link which currently specifies the controller and action, but of course the link doesn't work if I'm in the wrong area. I see no overload for actionlink that takes an area parameter, is it possible to do?

+9  A: 

Figured it out..

Html.ActionLink("Link Text", "ActionName", "ControllerName", new { Area = "AreaName" }, new{})
Jeremy
Yes this is a good approach.
Ravia
+3  A: 

Something I ran into right after this, that I imagine others might run into: If you need to link from within an area to an action not in an area, you still need to specify the Area as empty string.

For instance, I moved some MVC code into an area, and found I needed to update urls in the master page that referenced other pages on the site.

To specify an url to something not in an area, use

Html.ActionLink("Home", "Index", "Home", new { Area = "" }, new{})
Frank Schwieterman