开发者

trouble constructiing url encoded link

开发者 https://www.devze.com 2023-01-03 21:08 出处:网络
if i do this: <a target=\"_blank\" href=\"<%=Url.Encode(sitelink)%>\"> LINK TO SITE</a>

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

精彩评论

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