Hi I have an action link placed on http://localhost:1338/Tags/InternalTag/Test which I would like it to link to http://localhost:1338/News/News/DisplayArticle?ArticleID=b491bee6-772c-4184-804a-13e53e50aa3d
I used <%: Html.ActionLink("Test", "DisplayArticle", "News")%>
but this results in http://localhost:1338/Tags/News/DisplayArticle
After reading it again I think I might need some more info, but here is what I suggest so far.
I am assuming InternalTags is your Controller, And Test is your action.
To have
ArticleIDin the URL, you need to addArticleIDas a “routeValue“But this wont fix it completely.
Your page is located in Tags/InternalTag/Test
Your link on your test page is defined as:
Will resolve to: http://localhost:1338/Tags/News/DisplayArticle
If you add an ArticleID to the link (as below):
Alternatively:
This will resolve to
Tags/News/DisplayArticle?ArticleID={GUID}.Incase I have missed something I will cover a different angle:
To me Tags is the site you are on, which would make News is a completely different site, if you want to go there you will need to hardcode your link as: http://localhost:1338/News/News/DisplayArticle?ArticleID=b491bee6-772c-4184-804a-13e53e50aa3d.
If they are the same site you will need to sort out the routes in your Global.asax.
Maybe you can comment on my answer and I’ll edit this accordingly?
Edit After 1st comment:
If you can get the route mapping right, often using the Action link is enough to choose the correct route, it requires looking at how your routes are listed, and changing the order and default values used, to ensure the signatures are specific enough to choose the route you want.
To force the route to a specific choice you can use
Html.RouteLink(linkText,routeName,routevalues)This will allow you to control the exact route you want to use and then pass in the routeValues for the controller, action and ArticleID.