开发者

Absolute (external) URLs with Html.ActionLink

开发者 https://www.devze.com 2023-03-14 05:05 出处:网络
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())

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?


This works for me:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消