Forum Moderators: open
We've got an .asp page that uses
Response.ContentTypeand
Response.BinaryWriteto 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 filefiledownload.doc from <server>
however
a .txt(text/plain) when downloaded shows a prompt in IE:
You are downloading the filefiledownload.asp from <server>
Does anybody know how or why this happens? Is it a server setting or something on the client?
Josh
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.
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?).