The Request.QueryString contains the file path example Temp\file#hashName.jpg
protected void Page_Load(object sender, EventArgs e)
{
string filePath = Request.QueryString["fileName"];
iframes.Attributes.Add("src", filePath);
}
It then goes to the Markup where I have 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;
}
However, when I run it, a new window displays "The resource cannot be found." Description: HTTP 404. The resource you are looking for (or one of its dependencies) 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... When I used Server.UrlEncode and HttpUtility.UrlEncode(); it's converting / and # to their respective values but showing an error message
HTTP Error 400 - Bad Request.
Javascript Escape(), EncodeURI() and EncodeURIComponent() are also not working out. What should I do to escape the # sign? Does iframe accept # value in URL??? Kindly guide me through this.
Kind Regards, Hardik