<%: Html.ActionLink("Share Me", "Index", "Mall", new { username = Model.Username }, null)%>
results as expected according to mapped routes:
<a href="/Mall/Username">Share Me</a>
I however need it to not say Share Me but to show the absolute URL, as well as use the absolute URL as the href:
<a href="http://www.url.com/Mall/Username">http://www.url.com/Mall/Username</a>
I feel this isn't a hard task, but being very green in tackling MVC I'm having a hard time figuring it out.
Rather than using Html.ActionLink, you should have a look at Url.RouteUrl (which ActionLink uses internally anyway). Something like...
<% var myUrl = Url.RouteUrl("Default", new { action = "Mall", username = Model.Username }, Request.Url.Scheme).ToString() %>
<a href="<%:myUrl%>"><%:myUrl%></a>
Note the first parameter is the route name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With