Given the following string:
/MyController/MyAction/4
How do I generate a link within another controller’s action to link to the appropriate address?
If I do the following:
@Html.ActionLink("click", Url.Action(item.Link))
// where item.Link is where /MyController/MyAction/4 is stored
I get a link that resembles:
www.localhost.com/CurrentController/CurrentController/MyController/MyAction/4
I need to not have the “CurrentController” part (yes, there are two of them – I think that is because I am doing a @Html.ActionLink and an Url.Action).
How would I get my appropriate link?
If you already have the
/MyController/MyAction/4path you need stored initem.Link, could you just build the<a>tag yourself?