471,594 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

"file download" dialog box appears twice

I am invoking a file download using the following code:

Response.Clear();

Response.AddHeader("Content-Disposition", "attachment; filename=" +
downloadFile.Name);
Response.AddHeader("Content-Length", downloadFile.Length.ToString());

Response.ContentType = "application/octet-stream";

Response.WriteFile(downloadFile.FullName);

Response.End();

This works with one issue. The user is provided with the "File
Download" dialog box that provides them with the options (Open, Save,
Cancel, More Info) twice, forcing the user to click on "Open" twice.

There is one difference, the first time that the "File Download"
appears the check box "Always ask before opening this type of file" is
disabled and has a check in it. The second time it is enabled and the
status version is displayed behind the prompt. Clicking "Open" the
second time opens the file.

What would cause this behaviour - we have another application developed
in VB Visual Studio 2003 and the "File Download" works as expected
(first time).

Second thing where can one find documentation that describes the
available options for the "Response" (AddHeader, ContentType). The
documentation that I have found leaves much to be desired.

TIA
Scott M.

Oct 30 '06 #1
4 2976
A few more items we are using .NET 2.0 and are trying to get the server
to provide the files to be uploaded - the files do not reside in an
ASPNET directory.

Oct 30 '06 #2
Hi Scott,

Have you tried the following code instead?

Response.Redirect(downloadFile.FullName)
Second thing where can one find documentation that describes the
available options for the "Response" (AddHeader, ContentType). The
documentation that I have found leaves much to be desired.
IANA MIME Media Types:
http://www.iana.org/assignments/media-types/

I think the user agent can choose what is acceptable, so just in case don't
assume that you can always use anything in the list.

--
Dave Sexton

"L. Scott M." <sc*******@comcast.netwrote in message
news:11********************@f16g2000cwb.googlegrou ps.com...
>I am invoking a file download using the following code:

Response.Clear();

Response.AddHeader("Content-Disposition", "attachment; filename=" +
downloadFile.Name);
Response.AddHeader("Content-Length", downloadFile.Length.ToString());

Response.ContentType = "application/octet-stream";

Response.WriteFile(downloadFile.FullName);

Response.End();

This works with one issue. The user is provided with the "File
Download" dialog box that provides them with the options (Open, Save,
Cancel, More Info) twice, forcing the user to click on "Open" twice.

There is one difference, the first time that the "File Download"
appears the check box "Always ask before opening this type of file" is
disabled and has a check in it. The second time it is enabled and the
status version is displayed behind the prompt. Clicking "Open" the
second time opens the file.

What would cause this behaviour - we have another application developed
in VB Visual Studio 2003 and the "File Download" works as expected
(first time).

Second thing where can one find documentation that describes the
available options for the "Response" (AddHeader, ContentType). The
documentation that I have found leaves much to be desired.

TIA
Scott M.

Oct 31 '06 #3
Dave,

Thanks for the "Redirect", it opens the document immediately.

We were trying to have the prompt (file download dialog box), but
having our users push "Open" or "Save" twice is at minimum sloppy.

Will check out the site: http://www.iana.org/assignments/media-types/
if our "security" will let me - or - maybe their site is down
temporarily...... d:}

Thanks again,
Scott M.

Oct 31 '06 #4
Hi Scott,

http://www.iana.org/assignments/media-types/

Works fine for me :)

--
Dave Sexton

"L. Scott M." <sc*******@comcast.netwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Dave,

Thanks for the "Redirect", it opens the document immediately.

We were trying to have the prompt (file download dialog box), but
having our users push "Open" or "Save" twice is at minimum sloppy.

Will check out the site: http://www.iana.org/assignments/media-types/
if our "security" will let me - or - maybe their site is down
temporarily...... d:}

Thanks again,
Scott M.

Oct 31 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bill R via AccessMonster.com | last post: by
4 posts views Thread by Mark Rendle | last post: by
3 posts views Thread by Terry Olsen | last post: by
7 posts views Thread by Tim Slattery | last post: by
2 posts views Thread by barthelemy.von.haller | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.