I have a handler that I call when a link gets clicked. This handler gets the file contents from the DB and writes the contents to context.Response. I'd like to open this file as well along with it getting downloaded. Is this possible?
Asked
Active
Viewed 509 times
0
-
What do you mean "open"? Server side or client side? – Alexei Levenkov Apr 26 '12 at 19:51
-
@AlexeiLevenkov Client side. When the user clicks on a link to download the file, it should download as well as open for the user to see. – neuDev33 Apr 26 '12 at 19:53
2 Answers
1
no. it is not.
if its a bitmap file - then maybe becuase it doesnt have to be fully downloaded...
but forget about it. it is not the right way.
you cant open a file while it is being downloaded - its a filesystem - restriction

Royi Namir
- 144,742
- 138
- 468
- 792
-
I see. So then I can open it after it gets downloaded right? And the way to do it would be to access it at the location it got downloaded and then open it? – neuDev33 Apr 26 '12 at 19:41
-
-
It could be any type, .doc, .xls, .jpeg, .gif, etc etc. This is a file the user has attached, and they can attach any file type. – neuDev33 Apr 26 '12 at 19:44
-
-
Nope, it pretty much just downloads the file. When the link is clicked, I pass an Id to my handler, and the handler gets the related files from the DB and does a response.Write – neuDev33 Apr 26 '12 at 19:48
-
-
the response is straight to your browser. it is not being saved anywhere. you cant open the file – Royi Namir Apr 26 '12 at 19:57
1
You have no control over browser's behavior. It will either open in browser OR display open/save dialog.
You may try to render custom page with HTML view of the file and automatically trigger second download from that HTML page to force open/save dialog.

Alexei Levenkov
- 98,904
- 14
- 127
- 179