Avatar of Thranduil
Thranduil

asked on 

Problem with Response.Write in a secure page in Internet Explorer

I have a openFile.aspx page which contains the code to open a file according to the contentType. Right now I am using the following code to open the file in that page:

            Response.ContentType = strContentType;
            Response.AddHeader("Content-Type", strContentType);  
            Response.AddHeader("Content-Disposition", "inline;filename=" + fileName);
            Response.WriteFile(strUrl);
            Response.End();

Now, currently how it works is, if you click a link on some page say abc.aspx, it opens a openFile.aspx in a new popup window, passing it the URL of requested file.

now this works fine normally, but when the application is run on secure server, internet explorer shows an information bar in popup window saying "IE has blocked this website from downloading files on your computer." When I click on it and click Download File, instead of downloading file, it will open the original page(abc.aspx) in that popup window. However if I disable information bar from Internet options, it works fine. Please Help
Web BrowsersASPASP.NET

Avatar of undefined
Last Comment
Thranduil
Avatar of prairiedog
prairiedog
Flag of United States of America image

Can you post the code which generates the popup window?
Avatar of Thranduil
Thranduil

ASKER

Here's the javascript code that opens popup

function OpenPopup(url,id, name, attrib)
{
	var attArr = new Array()
	attArr = new Array("fileURL", url);
	attArr = new Array("fileID", id);
	var td = new Date();
	var rnd = new String(Math.round(td*1.0));
	eval("wnd_" + rnd + "=" + "window.open('','','" + attrib + "')");
	wndvar = eval("wnd_" + rn);
	with(wndvar.document)
	{
		clear();
		writeln("<HTML>");
		writeln("<Head>");
		writeln("<meta http-equiv='content-type' content='text/html;charset=iso-8859-1'>");
		writeln("<meta http-equiv='pragma' content='no-cache'>");
		writeln("<meta http-equiv='cache-control' content='no-cache, no-store, must-revalidate, max-age=0'>");
		writeln("<meta http-equiv='expires' content='0'>");
		writeln("<title>" + name + "</title>");
		writeln("</Head>");
		writeln("<body>");
		writeln("<form name='openFile' method='post' action='" + url + "'>");
		for(i=0; i<attArr.length; i++)
		{
            		var arr = attArr[i];
            		writeln("<input name='" + arr[0] + "' type='hidden' value='" + arr[1] + "'>");
		}
		writeln("</form>");
		writeln("</body>");
		writeln("</HTML>");
	}
}

Open in new window

Avatar of prairiedog
prairiedog
Flag of United States of America image

With your code, I believe any popup blocker will block the window.
Since you already have a page OpenFile.aspx, you can just use something like:
window.open("OpenFile.aspx?fileID=id" to open the popup window without triggering the popup blocker.
I need to know how you contruct the links on the abc.aspx to give you more specific information.
Avatar of Thranduil
Thranduil

ASKER

Actually the window pops up when I click the link, and it works fine. But, when the application is running on secure server, the window pops up but it wont display the download file message. It will show an information bar, and when i click on it and click download file, it will open abc,aspx inside the popup.

Also, I just tested it on firefox and it runs smoothly. Only IE is giving me problems

About the links, they are normal href links which call javascript:openPopup(...)
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Thranduil
Thranduil

ASKER

It worked... adding https://  to urlpath did it.
Can believe something this small baffled me for hours.

Thx for your help
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo