【发布时间】:2016-11-18 13:57:29
【问题描述】:
我在 .aspx 页面上有一个超链接
<asp:HyperLink ID="hlTest" runat="server" NavigateUrl="#">Test Link</asp:HyperLink>
在我的页面后面的代码上:
string link = "http://myDoman/myEmailAttachments/1436/" + HttpUtility.HtmlEncode("Picture of Jim&John.jpg");
hlTest.NavigateUrl = link;
这会生成一个如下所示的 url: http://myDomain/myEmailAttachments/1436/Picture%20of%20Jim&John.jpg
这会导致显示一条消息:检测到来自客户端 (&) 的潜在危险 Request.Path 值。
我尝试过使用 Server.Urlencode。这会产生一个看起来像 ...
http://myDomain/myEmailAttachments/1436/Picture+of+Jim%26John.jpg
这会导致显示相同的消息:检测到来自客户端 (&) 的潜在危险 Request.Path 值。
如果我有一个名为...的文件
Jim&John.jpg 的图片
...我怎样才能把它变成一个超链接,这样它才能真正去获取文件?感谢您的帮助。
【问题讨论】: