473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Response.WriteFile() Doesn't Trigger Download Managers

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
5 3661
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Claus Pedersen | last post by:
We are building a webapplication but keep hitting a wall: The user can download files but we need to check if they are authorized to do so. We do this with a download-page and use the following...
0
by: Earl Teigrob | last post by:
I have a datagrid with a download button that raises the itemcommand event. In the event handler for this event, I have the code below. The problem is that the download code requires a...
2
by: Carter | last post by:
i have a treeview on a webform (.aspx). when the user selects an appropriate node on the tvw. and clicks on a link button, i'm downloading a corresponding file to the client (from the server). so far...
0
by: ProJee | last post by:
Hi, Response.WriteFile (or Response.OutputStream.Write) finishes immediately, not after the file is completely downloaded. It finishes before (!) the user clicks the "Save" or "Open" browser...
2
by: David Union | last post by:
Hi. I'm posting this here because I don't know exactly what the best group is. This is for an aspx page with Visual Basic as the code-behind page. I am doing very simple code... in the middle...
3
by: Jocelyn Duhaylungsod | last post by:
I have been getting the following server errors sporadically while downloading excel, csv or xml file. Internet Explorer cannot download <file name> from <IP address> "The server returned an...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
3
by: MJP | last post by:
I have a button which kicks off the generation of a report after which the file will be downloaded. The report generation can take a long time, so client side onclick event of the button also...
2
by: Nathan Sokalski | last post by:
I have an application in which I want to allow users to view certain files that are on the server, but not part of the application. To do this, I figured I would have ASP.NET read the files and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.