Request.QueryString包含路徑 例如。 TEMP \文件#hashName.jpg哈希特殊字符在IFRAME中不起作用
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:/ Temp/file 只要遇到HASH,就會破壞路徑...我使用Server.URLEncode和HttpUtility.UrlEncode();其轉換/和#到相應的值... bt顯示消息
HTTP錯誤400 - 錯誤的請求。
Javascript Escape()EncodeURI()和EncodeURI組件也不工作。 我該怎麼辦才能逃避#? iframe是否接受URL中的#值?請通過此指導我。
親切的問候, Hardik
如何使用替換函數,如filePath = filePath.replace(/ \#/ ig,「」); – Max 2011-05-30 07:24:15
Hi Max!感謝您的回覆..保存時間它存儲d文件名##只有當在新窗口中查看它給這個問題...儘管我會嘗試它,讓你知道 – Hardik 2011-05-30 07:39:30