By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

"file download" dialog box appears twice

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.