By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

Response.WriteFile() Doesn't Trigger Download Managers

P: n/a
Hi guys,

i am building a FileSharing website,
i wanna allow users to be able using download managers such as DAP to
download files from webserver but
don't allow them to retrive files url...
so i used Response.WriteFile but it won't trigger any download manager
such as DAP or FlashGet

i used this code :
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=MyFile.zip");
Response.AddHeader("Accept-Ranges", "bytes");
Response.AddHeader("Etag", "\"90a94a56b3bcc71:bea\"");
Response.WriteFile(file_path);
Response.End();

Thanks In Advance

Aug 15 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hello Khafancoder,
Hi guys,

i am building a FileSharing website,
i wanna allow users to be able using download managers such as DAP to
download files from webserver but
don't allow them to retrive files url...
so i used Response.WriteFile but it won't trigger any download manager
such as DAP or FlashGet
i used this code :

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=MyFile.zip");
Response.AddHeader("Accept-Ranges", "bytes");
Response.AddHeader("Etag", "\"90a94a56b3bcc71:bea\"");
Response.WriteFile(file_path);
Response.End();
Thanks In Advance
Usually these download managers don't work if the download originates from
a postback. Make sure you're using a normal link to the download page. And
that the download page immediately presents the user with the requested download
based on the query string information.

--
Jesse Houwing
jesse.houwing at sogeti.nl
Aug 15 '07 #2

P: n/a
Thanks Jesse,

here is what exatcly happening :

my client wants to redirect all users to his domain for downloading
any file from his website...
(in fact he don't want that users be able to download his files from
links which placed in other sites or forums directly)
so we decide to make downloads available by clicking on a button in a
special page (such as RapidShare)
but he also wants his users could use download managers...

Thanks
On Aug 15, 3:51 pm, Jesse Houwing <jesse.houw...@newsgroup.nospam>
wrote:
Hello Khafancoder,
Hi guys,
i am building a FileSharing website,
i wanna allow users to be able using download managers such as DAP to
download files from webserver but
don't allow them to retrive files url...
so i used Response.WriteFile but it won't trigger any download manager
such as DAP or FlashGet
i used this code :
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=MyFile.zip");
Response.AddHeader("Accept-Ranges", "bytes");
Response.AddHeader("Etag", "\"90a94a56b3bcc71:bea\"");
Response.WriteFile(file_path);
Response.End();
Thanks In Advance

Usually these download managers don't work if the download originates from
a postback. Make sure you're using a normal link to the download page. And
that the download page immediately presents the user with the requested download
based on the query string information.

--
Jesse Houwing
jesse.houwing at sogeti.nl

Aug 15 '07 #3

P: n/a
Hello Khafancoder,
Thanks Jesse,

here is what exatcly happening :

my client wants to redirect all users to his domain for downloading
any file from his website...
(in fact he don't want that users be able to download his files from
links which placed in other sites or forums directly)
so we decide to make downloads available by clicking on a button in a
special page (such as RapidShare)
but he also wants his users could use download managers...
Thanks
you'd have to make a 2-step download. On the landing page (the one with the
busson) set a flag in the session or set a cookie. Then do a response.redirect
to the download page, passing the query string parameters again. On the download
page check if the session variables or the required cookie is there. If it
is, proceed with the download. If it's not server.transfer back to the landing
page.

Jesse
>
On Aug 15, 3:51 pm, Jesse Houwing <jesse.houw...@newsgroup.nospam>
wrote:
>Hello Khafancoder,
>>Hi guys,

i am building a FileSharing website,
i wanna allow users to be able using download managers such as DAP
to
download files from webserver but
don't allow them to retrive files url...
so i used Response.WriteFile but it won't trigger any download
manager
such as DAP or FlashGet
i used this code :
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=MyFile.zip");
Response.AddHeader("Accept-Ranges", "bytes");
Response.AddHeader("Etag", "\"90a94a56b3bcc71:bea\"");
Response.WriteFile(file_path);
Response.End();
Thanks In Advance
Usually these download managers don't work if the download originates
from
a postback. Make sure you're using a normal link to the download
page. And
that the download page immediately presents the user with the
requested download
based on the query string information.
--
Jesse Houwing
jesse.houwing at sogeti.nl
--
Jesse Houwing
jesse.houwing at sogeti.nl
Aug 15 '07 #4

P: n/a
Thank you for reply,
>>Usually these download managers don't work if the download originates from
a postback.

i think because it's a POST request, right ?

so,i change it to a GET request by calling download function in
Page_Load...

but sometimes it trigger download manager and sometimes it doesn't (on
IE), and in firefox download manager never triggered !

of course when i make request to a physical file, in both of them (IE
& FF) DAP will handle the downloads.

so i monitor HttpHeaders diffrence between these requests ("my GET
request" and "calling file directly") and both of them send the same
request to IIS

and finally ! yes i forget something ! it's because of the .aspx
extension !!! DAP won't handle this extension.

so i used your solution (two pages for downloads) and paste the
extension of requested file -as a querystring parameter- to url of
second page, and it works !

Thank you so much Jesse
i used this code :
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=MyFile.zip");
Response.AddHeader("Accept-Ranges", "bytes");

Response.WriteFile(path);
Response.End();

Aug 15 '07 #5

P: n/a
Hello Khafancoder,
Thank you for reply,
>>Usually these download managers don't work if the download
originates from
a postback.

i think because it's a POST request, right ?

so,i change it to a GET request by calling download function in
Page_Load...

but sometimes it trigger download manager and sometimes it doesn't (on
IE), and in firefox download manager never triggered !

of course when i make request to a physical file, in both of them (IE
& FF) DAP will handle the downloads.

so i monitor HttpHeaders diffrence between these requests ("my GET
request" and "calling file directly") and both of them send the same
request to IIS

and finally ! yes i forget something ! it's because of the .aspx
extension !!! DAP won't handle this extension.

so i used your solution (two pages for downloads) and paste the
extension of requested file -as a querystring parameter- to url of
second page, and it works !

Thank you so much Jesse

i used this code :

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=MyFile.zip");
Response.AddHeader("Accept-Ranges", "bytes");
Response.WriteFile(path);
Response.End();

You're welcome :)

--
Jesse Houwing
jesse.houwing at sogeti.nl
Aug 15 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.