开发者

trouble constructiing url encoded link

if i do this:

  <a target="_blank" href="<%=Url.Encode(sitelink)%>"> LINK TO SITE</a>

I get the link enc开发者_如何学Pythonoded but prepended with the current local domain "http://localhost/http://...."

whats the proper way to do this


The Url.Encode method is used to escape special characters for usage in the query part of a url - it's not meant to be applied to the entire url, because that will escape things like the :// at the beginning (which is why you get the local domain prepended, because it's no longer a full URL, instead getting interpreted as a relative url).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜