|
 |
asp_web_howto thread: How to immediately rediriet user to download a file
Message #1 by "Premek Vacek" <premek_v@e...> on Tue, 19 Mar 2002 20:56:58
|
|
Hello,
I have one problem: I need some asp method how to immediately download a file after opening a web page.
I want users of my webserver (they log in to gain acces - authentication is done via asp) to be able to download some files
from it, but I don't want any non-logged users to be able to do so. Because if those non-logged users know absolute address to a
file, they can still download it. So i realized that I can send their request to for example download.asp, then do some
authentication, and then this script should download destination file from secret area (for user: the pop-up dialog "Save as..."
will appear).
But when I used redirection methods such as Response.Redirect or Server.Execute, it didn't work. These methods support just
redirection to http link, but not to a file (when i tried it, the browser showed the content of that file).
example how it should work:
- user clicks on link to default.asp with parametr some that represents the name of the file.
- download.asp processes this request, generates some page with notice that pop-up dialog "Save as.." should appear immediately
- dialog appears and user downloads the file
I would be very happy if someone could help me with this problem.
Thanks,
Premek Vacek
PS: Sorry for grammar mistakes (I am from Czech Rep.)
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 20 Mar 2002 13:30:02 +1100
|
|
You need to Response.BinaryWrite() the data
Pass a parameter indicating which file needs to be sent to the user.
Use the parameter to set the Response.ContentType, and to
Response.BinaryWrite() the information to the client. The user should see
the Save As... dialogue.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Premek Vacek" <premek_v@e...>
Subject: [asp_web_howto] How to immediately rediriet user to download a file
: Hello,
:
: I have one problem: I need some asp method how to immediately
download a file after opening a web page.
: I want users of my webserver (they log in to gain acces -
authentication is done via asp) to be able to download some files from it,
but I don't want any non-logged users to be able to do so. Because if those
non-logged users know absolute address to a file, they can still download
it. So i realized that I can send their request to for example download.asp,
then do some authentication, and then this script should download
destination file from secret area (for user: the pop-up dialog "Save as..."
will appear).
: But when I used redirection methods such as Response.Redirect or
Server.Execute, it didn't work. These methods support just redirection to
http link, but not to a file (when i tried it, the browser showed the
content of that file).
:
: example how it should work:
: - user clicks on link to default.asp with parametr some that represents
the name of the file.
: - download.asp processes this request, generates some page with notice
that pop-up dialog "Save as.." should appear immediately
: - dialog appears and user downloads the file
:
: I would be very happy if someone could help me with this problem.
: Thanks,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |