开发者

Hash Special character does not work in IFRAME

The Request.QueryString comprises of the path eg. Temp\file#hashName.jpg

protected void Page_Load(object sender, EventArgs e)
{
string filePath = Request.QueryString["fileName"];
iframes.Attributes.Add("src", filePath);
}

it den goes to the Markup where i hav written javascript code

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;
}

but when I run, it shows me (in a new window) "The resource cannot be found. " Description: HTTP 404. The resource you are looking for (or one of its dependenci开发者_JAVA百科es) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Temp/file as soon as it encounters a HASH it breaks the path... wen I used Server.URLEncode and HttpUtility.UrlEncode(); its converting / and # to respective values... bt showing message

HTTP Error 400 - Bad Request.

Javascript Escape() EncodeURI() and EncodeURI component s also not working out. What shall I do to escape # ?? does iframe accept # value in URL??? Kindly guide me through this.

Kind Regards, Hardik


Where does ViewFile js function get the input filePath? Issue can be related to that. If the filePath has # in it then you can use encodeURIComponent such as

'ViewFile.aspx?fileName=' + encodeURIComponent(filePath)

However, there will be issue if filePath value to function is not correct because encoding issue elsewhere (e.g. IFrame source). Whenever you use # in URL/QueryString, it may cause an issue - so you should also try to escape it while assigning it to IFrame source.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜