Absolute (External) URLs Using Html.ActionLink

I cannot get Html.ActionLink to create absolute urls.

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

This correctly pulls data from my model, but adds the path to the end of the current page, creating URLs such as "http: // localhost: 24590 / www.google.com"

How can I make it work as I want?

+6
source share
2 answers

Use an absolute URL starting with ie http:// .

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

would have the same result because it is a relative url.

+8
source

This works for me:

 <a href="http://@Model.URL"> Click Here </a> 
+13
source

Source: https://habr.com/ru/post/891012/


All Articles