ASP.NET:HttpUtility.UrlEncode停止添加我们的网站前缀?

时间:2015-10-22 00:20:18

标签: asp.net vb.net

有没有办法阻止HttpUtility.URLEncode始终为我们用自己网站的网址提供的任何原始网址加前缀? (例如http://localhost:45852/LocalSite/pages/display

例如:

 Dim strReturn As String = ""

 strReturn += "http://maps.apple.com/?q="
 strReturn += vClsVendor.pAddressLine1.Trim
 strReturn += "+"
 strReturn += vClsVendor.pAddressLine2.Trim

 strReturn = HttpUtility.UrlEncode(strReturn)

给出以下结果:

http://localhost:453432/LocalSite1/pages/display/http%3a%2f%2fmaps.apple.com%2f%3fq%3d1+McDonald%2527s+Way%2bRonaldville

而不是:

http%3a%2f%2fmaps.apple.com%2f%3fq%3d1+McDonald%2527s+Way%2bRonaldville

TIA 标记

2)回复Scotty:

谢谢Scotty。我把断点放进去测试了。在UrlEncode之后它仍然可以。事实证明,ASP.NET在<%= strClsGridHTML%>处加前缀。其中strClsGridHTML包含以下href内容:

href='http%3a%2f%2fmaps.apple.com%2f%3fq%3d123+Water+Way%2bAtlantic%2bDenpasar%2bBali%2b123432%2bIndonesia     '>   




 <div id="dvGrid01">
            <asp:HiddenField ID="HiddenFieldSearch" runat="server" Value="0" />
            <%=strClsGridHTML%>

             <div style="clear:both;"></div>

        </div>

因此,ASP.NET可能会查看http%3a%2f%2fmaps.apple.com%2f%3fq%3d123 + Water + Way%2bAtlantic%2bDenpasar%2bBali%2b123432%2bIndonesia并确定它不是已经有效的URL所以决定用localhost位作为前缀吗?

0 个答案:

没有答案