Forum Moderators: open

Message Too Old, No Replies

Downloading files from a database

via an .ASP page

         

joshie76

11:54 am on Aug 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure where to post this question but I've decided here because the odd behaviour is on the client and I suspect it may be down to client settings.

We've got an .asp page that uses

Response.ContentType
and
Response.BinaryWrite
to download files and we're observing some odd behaviour. Say, for example, the asp page is called filedownload.asp

a .doc (application/msword) when downloaded shows a prompt in IE:

You are downloading the file

filedownload.doc from <server>

however

a .txt(text/plain) when downloaded shows a prompt in IE:

You are downloading the file

filedownload.asp from <server>

Does anybody know how or why this happens? Is it a server setting or something on the client?

Josh

korkus2000

6:11 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you ever find an answer to this?

joshie76

7:28 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, why have you run into it too?

I did quite bit of research into the whole matter and think I've got a fair understanding as to why it's happening, unfortunately that's also led me to think it simply can't be corrected.

I hope I'm wrong (and you're just waiting to give me the answer!)

korkus2000

7:29 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is your code for the stream? I have found some stuff online but it is very specific so I wanted to see if it is your problem.

corby0000

5:05 am on Sep 25, 2002 (gmt 0)

10+ Year Member



Have you tried the content-disposition extension of the MIME protocol? This tells the user agent how to display the attached file. Here's an example:

Response.AddHeader "Content-Disposition", "attachment, filename=Test.txt"

Appending this to your code should force the browser to prompt the user to open the file or save it to disk. It also allows you to specify the file name for the attached file.

I don't think it really applies but here's some additional information on the extension:

[pasteur.fr ]

Hope this helps.

joshie76

12:44 pm on Sep 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Corby - you're a genious! It worked a treat, thank you!

However, some people get an 'Action cancelled' screen below the 'Open/Save' dialog. Any idea how to stop this?

corby0000

8:47 pm on Sep 30, 2002 (gmt 0)

10+ Year Member



It probably has something to do with your response. Can you be a little more descriptive on what it is you're tring to do. Besides the binary stream, is there anything else in your response?

joshie76

8:13 am on Oct 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, just binary - here's an example:

Response.ContentType = "text/plain" 
Response.AddHeader "Content-Disposition", "inline; Filename=test.txt"
Response.BinaryWrite(BinaryFromDatabase)

And it now works a treat but for the 'Action Cancelled' page that some users see (we chose to use inline as this opened in the browser, whereas if we used attachment you got two open/save dialogs - as I think about it do you know how you stop that - as then our problem is solved?).