Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Absolute (external) URLs with Html.ActionLink

I'm unable to get Html.ActionLink to produce absolute urls.

Html.ActionLink(DataBinder.Eval(c.DataItem, "Name").ToString(), DataBinder.Eval(c.DataItem, "Path").ToString())

This pulls the data from my model correctly, but appends the path to the end of the current page, producing URLs like "http://localhost:24590/www.google.com"

How can I get this to work how I want it to?

like image 437
Skrealin Avatar asked Jun 21 '11 13:06

Skrealin


2 Answers

This works for me:

<a href="http://@Model.URL">
    Click Here
</a>
like image 169
Nick Howard Avatar answered Sep 18 '22 02:09

Nick Howard


Use an absolute URL starting with i.e. http://.

<a href="www.google.com"></a>

would have the same result, because it's a relative url.

like image 32
DanielB Avatar answered Sep 21 '22 02:09

DanielB