ASP.NET Forced Download Not Working

X

xeroxero

I am attempting to make a small popup window push a downloaded file.
What works fine with the Visual Studio 2005 web server does not appear
to work with IIS6.

My main page code looks like this:

LiteralControl litMove = new LiteralControl();
litMove.Text = @"
<script language='JavaScript'>
<!--
var dlWindow = window.open('theFile', 'fileDl',
'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=10,left=10,height=24');
//-->
</script>
";
litMove.Text = litMove.Text.Replace( "theFile" , theFile );
this.pageBody.Controls.Add( litMove );



The actual download code (in a new page appearing as "theFile" in the
previous code page above) looks like this:

Response.Clear();
Response.AddHeader( "Content-Disposition" , "attachment;filename=" +
HttpUtility.UrlPathEncode(myFile) );
Response.AddHeader( "Content-Length" , new FileInfo( fullFilePath
).Length.ToString() );
Response.ContentType = "application/octet-stream";
Response.TransmitFile( fullFilePath );
Response.End();

What happens is that on IIS6, the popup appears for 1/2-second and
disappears. On the Visual Studio Cassini server, the window appears
and then the user is prompted for save.

Users are IE7 clients.

Thanks.
 
T

tmb

I am attempting to make a small popup window push a downloaded file.
What works fine with the Visual Studio 2005 web server does not appear
to work with IIS6.

I'm pretty sure it is not related to the webserver. Why it appears to
work in VS2005 is because you have different settings in IE7 because
of the zones (Internet vs Local Intranet) and they have different
settings for 'Automatic prompting for file downloads'. Local Intranet
has it set to on while Internet has it set to off which results in
this behaviour on remote sites. Set Local Intranet to the same setting
as Internet and you can get the same effect. IE6/Firefox works as
expected.

It works if you for example have a button on the page that opens the
window directly by javascript and pushes the file directly into the
window. The problem for me is that in my case i have a webform that
needs to be posted first and saved and the result is then displayed in
a new window opened by javascript. This asynchronous behaviour seems
to trigger something in IE7 so the window is closed right away.
Extremely irritating...

One workaround is to tell the users to change the setting in IE7 so it
works as intended but that is not an optimal solution.

If you find a solution please post it here.

Regards TMB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top