How to specify an area name in an action link?

Figured it out..

Html.ActionLink("Link Text", "ActionName", "ControllerName", new { Area = "AreaName" }, new{})

Use:

 Html.ActionLink("Text", "ActionName", "ControllerName", new { Area = "AreaName" }, null)

Note:4th parameter is to pass route Values, if you pass an empty parameter it will consider root structure and if you pass appropriate value it use it as area.

Also do not forget to use null or new{} as the 5th parameter because passing null or new {} while creating action link will not overload method for (text,action,controller,route data) or its (text,action,controller,route data,html attribute) so use the proper method


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", new { area = "", controller = "Home" })

In MVC2 giving area="root" worked for me as below

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