0

Creating an AnchorTag in a Razor page table. The table cell with the OrderNbr needs to be a link to the website (e.g. https://host/main?OrderNbr=012345) with the order using the routevalue of the OrderNbr.

Using asp-host tag helper and getting unexpected results:

@Html.ActionLink(item.OrderNbr, null, null, "https", "host/main", null, Model.routeValues, new Dictionary<string, string> {{"target","_blank"}} )

I'm using ActionLink to create the anchor tag in a cshtml razor page table.

expected result:

<a href="https://host/main?routeValue1&?routeValue2" target="_blank">Order Number Value</a>

actual result:

<a href="https://host/main/Area/Page/Details?routeValue1&?routeValue2" target="_blank">Order Number Value</a>

My issue is that if creates it fine EXCEPT that it appends the page route to the host address specified which I didn't expect? The docs do not show this so is this a bug?

Thanks for any insights and assistance.

Steven
  • 1
  • 2
  • Does this answer your question? [How to build a query string for a URL in C#?](https://stackoverflow.com/questions/829080/how-to-build-a-query-string-for-a-url-in-c) – daremachine Oct 20 '22 at 00:34
  • you probably need generate query parameters instead of use Helper.Action which generate url from controllers. Check this and make your url link yourself https://stackoverflow.com/a/58525660/1795390 – daremachine Oct 20 '22 at 00:36
  • Could you please share your controller which you are trying to call. – Md Farid Uddin Kiron Oct 20 '22 at 10:01
  • @md-farid-uddin-kiron I am attempting to construct a url that calls another website with specific routevalues. The asp-host parameter creates the specified domain/host BUT the pages route the href is created in is being added to this domain/host. Why? – Steven Oct 20 '22 at 18:13
  • Could you please share more details ho you are getting `Model.routeValues` and what actually you are getting on that. It doesn't seems clear. – Md Farid Uddin Kiron Oct 21 '22 at 09:26

0 Answers0