【发布时间】:2011-09-04 14:59:00
【问题描述】:
Request.QueryString 包含路径 例如。临时\文件#hashName.jpg
protected void Page_Load(object sender, EventArgs e)
{
string filePath = Request.QueryString["fileName"];
iframes.Attributes.Add("src", filePath);
}
它转到我编写 javascript 代码的标记
function ViewFile(filePath) {
var width = 800;
var height = 450;
var left = (screen.width / 2) - (width / 2);
var top = (screen.height / 2) - (height / 2);
window.open('ViewFile.aspx?fileName=' + filePath, 'CustomPopUp', 'width=' + width + ', height=' + height + ',toolbar=no,menubar=no,directories=no,resizable=yes,scrollbars=yes,location=no,top=' + top + ',left=' + left);
return false;
}
但是当我运行时,它会显示(在新窗口中) “没有找到您要查的资源。 ” 说明:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。
请求的 URL:/Temp/file 一旦遇到 HASH,它就会破坏路径...... 我使用了 Server.URLEncode 和 HttpUtility.UrlEncode();它将 / 和 # 转换为各自的值... bt 显示消息
HTTP 错误 400 - 错误请求。
Javascript Escape() EncodeURI() 和 EncodeURI 组件也无法正常工作。 我该怎么做才能逃脱#?? iframe 是否接受 URL 中的 # 值???请指导我完成此操作。
亲切的问候, 哈迪克
【问题讨论】:
-
使用替换函数怎么样,filePath = filePath.replace(/\#/ig, "");
-
嗨,麦克斯!!感谢您的回复..在节省时间的同时,它使用#...存储 d 文件名...仅在在新窗口中查看它时会出现此问题...尽管我会尝试并让您知道
标签: c# javascript asp.net .net-3.5