Search code examples
asp.net-mvchtml.actionlink

How do I create an ActionLink to the Index action of a different controller?


How do I change the following code to produce the proper URL?

Note: The ActionLink is being produced from a different controller than DomainsController.

@Html.ActionLink("Domains", "Index", "Domains", new { id = item.Name }, null)

The goal is to see the following URL.

/Domains/ItemName

What I'm getting is:

/Domains/Index/ItemName

Any help is greatly appreciated.


Solution

  • Strange routing :)

    Here goes quick and dirty solution:

    @{string link= "Domains/" + item.Name;}
    @Html.ActionLink("Domains", "", link, null, null)