472,958 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 3065
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luis Ferrao | last post by:
Hi, My Windows Forms application uses the WebBrowser control to open an Excel file since OLE objects are gone in .Net. The application is actualy a clone of the one found in the MS Knowledge...
0
by: Bill R via AccessMonster.com | last post by:
I have a procedure that runs when you dbl click in a txt box. It runs the docmd.acCmdHyperLink command. I am trying to find a way to have the "Insert Hyperlink" dialog box default to "Browse For"...
4
by: Mark Rendle | last post by:
Hi I'm writing a page which outputs CSV data for download. It's all working fine, setting ContentType to "text/csv", except when the "Open/Save" dialog appears, the filename shown is...
3
by: Terry Olsen | last post by:
I followed the information in a previous thread, but i'm having problems. I have a couple dropdownlists and a submit button on my form. The user selects choices from the lists and clicks the...
0
by: Ibrahim. | last post by:
Hello, The problem I'm facing is that the file name that is displayed in File download diaglog of web page displays garbled. The file name is japanese. English names works fine. Dim...
10
by: vunet.us | last post by:
What is the workaround of passign a parameter to any included asp file: <!-- #Include File="file.asp" --> This obviously does not work: <!-- #Include File="file.asp?id=123" --> Thank you
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
2
by: nedu | last post by:
Hi, Since I need to insert a a excel file in the HTML, I used <iframe> tag. But this tag PROMPT me the "File Download" dialog box every time the page got refreshed. Is there any ASP code to block...
2
by: barthelemy.von.haller | last post by:
Hello ! I am having a problem which I thought was an easy one but which starts to drive me crazy. Imagine that I have a text displayed in a div. I would like a button to download a text file...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.