473,548 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.WriteF ile() 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.WriteF ile but it won't trigger any download manager
such as DAP or FlashGet

i used this code :
Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ;
filename=MyFile .zip");
Response.AddHea der("Accept-Ranges", "bytes");
Response.AddHea der("Etag", "\"90a94a56b3bc c71:bea\"");
Response.WriteF ile(file_path);
Response.End();

Thanks In Advance

Aug 15 '07 #1
5 3671
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.WriteF ile but it won't trigger any download manager
such as DAP or FlashGet
i used this code :

Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ;
filename=MyFile .zip");
Response.AddHea der("Accept-Ranges", "bytes");
Response.AddHea der("Etag", "\"90a94a56b3bc c71:bea\"");
Response.WriteF ile(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.nospa m>
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.WriteF ile but it won't trigger any download manager
such as DAP or FlashGet
i used this code :
Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ;
filename=MyFile .zip");
Response.AddHea der("Accept-Ranges", "bytes");
Response.AddHea der("Etag", "\"90a94a56b3bc c71:bea\"");
Response.WriteF ile(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.redire ct
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.nospa m>
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.WriteF ile but it won't trigger any download
manager
such as DAP or FlashGet
i used this code :
Response.Cont entType = "applicatio n/octet-stream";
Response.AddH eader("Content-Disposition", "attachment ;
filename=MyFi le.zip");
Response.AddH eader("Accept-Ranges", "bytes");
Response.AddH eader("Etag", "\"90a94a56b3bc c71:bea\"");
Response.Writ eFile(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.houwin g 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.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ;
filename=MyFile .zip");
Response.AddHea der("Accept-Ranges", "bytes");

Response.WriteF ile(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.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ;
filename=MyFile .zip");
Response.AddHea der("Accept-Ranges", "bytes");
Response.WriteF ile(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
360
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 code: public void ProcessRequest(HttpContext context) { context.Response.Clear(); context.Response.AppendHeader("Content-Disposition", "attachment;...
0
1457
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 Response.End() in order to stop further output the the response stream(such as the posted back page itself). Is there a way to divert the output stream back to...
2
5719
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 so good. all of that works. after the download, i want to refresh the treeview and redisplay the current node with a different color. and also...
0
1974
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 button, file size doesn't matter. I'm not possible to track if the file was completely downloaded or if the user only clicked the link and cancelled...
2
4163
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 of an http request, i set a filename (with path) and do a Response.WriteFile(filenamewithpath) then Response.End(). I have tried Response.Clear()...
3
3849
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 invalid or unrecognized response" / "The connection with the server was reset" I'm using Response.BinaryWrite to send down the file content as...
3
6311
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 these files teh time that it takes until the client displays the Save As dialog can be extrordinarily long (3+ minutes). I don't understand why. I...
3
10397
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 makes a <span> tag visible which contains a nice message to the user thanking them for their patience. Of course after the report has been generated...
2
2012
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 send them to Response. I have done this with images by reading them into a Bitmap object and then using the following code: Response.ClearContent()...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7444
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.