Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 8th, 2008, 07:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count Downloads; TransmitFile

Hi There.

It has been a while since I have been in here, but have had some good experiences in here. Now I have a problem I do not seem to be able to solve, or rather do not know how to go about, though I tried Google.

Well, I want to count the number of times a file has been downloaded. Not just how many times some button has been clicked on the site, but one count for a succesfull download. If you use e.g. the TransmitFile method like this...
Code:
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.AddHeader(
    "Content-Disposition", "inline; filename=" + System.IO.Path.GetFileName(path));
HttpContext.Current.Response.ContentType = "application/zip";
HttpContext.Current.Response.TransmitFile(path);
HttpContext.Current.Response.End();
... you will get a dialog in which you can Cancel og Save, therefore counting on the button click that started the download will not suffice since Cancel would count for one.

I once saw... or should I say... heard about the download functionality at allofmp3.com. At this site it was only possible to download some file once and it worked beautifully, even it the download was interrupted, but how?

Thanks, Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
  #2 (permalink)  
Old June 8th, 2008, 05:00 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I can only make some guesses about this. But...

I think there is a way to test some property on the Response class to see if it is still connected to the client browser (i.e. they haven't canceled the request or the connection broke, etc). If you do this test at the end of the code behind for this page or handler it might be enough to determine that the user made a completed download. Then it's just a matter of saving that information somewhere, like a database.

-Peter
compiledthoughts.com
  #3 (permalink)  
Old June 9th, 2008, 05:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Peter...

Nice to see that you are still in here sharing your experiences. I will explore the Response class in greater depth and post my findings.

Thanks, Jacob.


Similar Threads
Thread Thread Starter Forum Replies Last Post
downloads JimBloomfield BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 June 23rd, 2006 09:17 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
Downloads alexisb BOOK: Expert One-on-One Access Application Development 7 January 1st, 2005 10:24 PM
C# Downloads Mike Smith Wrox Book Feedback 3 December 14th, 2003 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.