When you add the following mapping:
routes.MapRoute("hierarchy", "{action}/{*url}"
new { controller = "Home", action = "Index" });
you can obtain the string 'url' in your action method:
public ActionResult myAction(string url)
{
...
}
The hierarchy is then easily obtained:
string[] hierarchy = url.Split('/');
Creating an url from a list of string values can be done using a similair approach:
string firstPart = hierarchy.Count() > 0: hierarchy[0] : string.Empty;
StringBuilder urlBuilder = new StringBuilder(firstPart);
for (int index = 1; index < hierarchy.Count(); index++)
{
urlBuilder.Append("/");
urlBuilder.Append(hierarchy[index]);
}
urlBuilder can then be used in an action link, for example:
<%= Html.ActionLink("Text", new { Controller="Home", Action="Index", Url=urlBuilder.ToString() }) %>