BlogEngine.NET extension: Detailed Download Counter

by Geert 1. January 2009 23:09

Lately, I have been posting some source code and I wanted to know how many times the source code was downloaded. I searched the internet and quickly found an Extensions page on the official BlogEngine.NET website. I noticed there were several different download counters available. I will list them here shortly with the cons and the pros.

1) Counter Extension by RTur

  • Stores every download (so advanced statistics are available)
  • The overview is not an overview (counts per file are not available)

2) Simply Download Counter by Al Nyveldt

  • Download count is displayed in the blog posts itself
  • No settings available to determine who can view the download count
  • Downloads are not stored separate (only the number of downloads per file)

3) File Download Tracker by Chris Blakenship

  • It shows a good overview which file is downloaded how many times
  • Downloads are not stored seapare (only the last download date and the number of downloads per file)

None of these counters could provide the functionality I really wanted. I simply wanted a counter that allowed me to decide at run-time whether I wanted anonymous users to be able to view the number of downloads. Also, I wanted a more structured way of storing and viewing the downloads per file. Since the original extensions didn't too look difficult, I decided to dive into the world of BlogEngine.NET extensions.

What I have developed is a solution that fits my needs (and probably others as well). The Detailed Download Counter saves the information per file, but also stores the timestamp, user agent and user host. This gives anyone the ability to create more advanced statistics. For the moment, I have only implemented a grid which simply shows an overview of the files downloaded and the details of a file. To get a grip of the current implementation, please view the image below:

To install the Detailed Download Counter extension, simply extract the zip file to the root or your BlogEngine.NET application. 

DetailedDownloadCounter.zip (6.69 kb) [Downloads: 1527]

kick it on DotNetKicks.com

A Detailed Download Counter that can be easily used with BlogEngine.NET

Tags:

ASP.NET | C#

Comments (17) -

Jim
Jim United States
2/18/2009 2:47:25 PM #

Thanks for sharing this, it looks nice and what I am looking for.  I have added it to my blog and see that it shows in Extension Manager.  But after download a file, I do not see anything show in the Extension Manager when clicking on the Settings link.  

Also, other extensions Picasa from RTUR no longer work...?

Geert van Horrik
Geert van Horrik Netherlands
2/18/2009 2:50:31 PM #

I am not sure about the Picasa extension, but it is strange that nothing shows up.

Do you really mean nothing, or just no downloads?

Jim
Jim United States
2/18/2009 2:50:37 PM #

Maybe I should be asking how to add a link to a file to download?  I just added a link to the zip file in a folder on my server.  See my downloads page.

Geert van Horrik
Geert van Horrik Netherlands
2/18/2009 2:53:40 PM #

I use the editor to add files (since they are uploaded automatically in that case as well). However, the script looks at the following handler:

../../file.axd?file=2009%2f1%2fDetailedDownloadCounter.zip

So, instead of directly linking to Studio.zip, you should use ../../file.axd?file=[YOUR FILE THAT THE HANDLER CAN FIND]

Jim
Jim United States
2/18/2009 4:35:47 PM #

Ok, I was manually FTPing the file to a directory.  I now used the post edit feature and uploaded the file and now using the proper link with /file.axd?file=.  I downloaded it twice (both logged in and not logged in) and I still do now see any downloads showing up.

Geert van Horrik
Geert van Horrik Netherlands
2/18/2009 4:41:55 PM #

Some things to check:

1) Is the add-in enabled? (you can check this by enabling the count visibility for non-authenticated users, download 0 should show up in that case).

2) Is a file being created (DetailedDownload.xml) in App_Data?

Jim
Jim United States
2/18/2009 5:02:51 PM #

Yes, the add-in is enabled.  I changed a setting for "Show download count for authenticated users only" a few times.  I verified the DetailedDownload.xml file is in App_Data\DataStore\Extensions.

Any thing else?  Picasa and LightBox extensions still not working either... I think it is all tied together some how.  I modified the web.config and uploaded it again to reset it all, but no luck.

Jim
Jim United States
2/18/2009 5:11:21 PM #

I've tried Disableing them all and then re-enabling them all, but no luck.  By the way, everytime I add an Add-in or Disable/Enable, I get a .net error, refresh and then it works.

Error:
The process cannot access the file 'c:\hosting\webhost4life\member\jrblack10\Jim\App_Data\datastore\extensions\AkismetExtension.xml' because it is being used by another process.

Geert van Horrik
Geert van Horrik Netherlands
2/18/2009 5:20:36 PM #

Strange, maybe you found a bug in BlogEngine.NET. I suggest you post this bug there since it seems all your extensions have stopped working.

Jim
Jim United States
2/20/2009 8:58:12 PM #

I removed a few extensions and re-added them, now Picasa, LightBox work again.  Added your extension again and nothing broke, but your extension does not seem to record any file downloads.  The files are .zip fils and they are uploaded with the blog interface using the proper "/file.axd?file=[YOUR FILE]" in the link.

Interestingly... I have tried 2 other download counters for BlogEngine and I can't get any of them to work.

Any suggestions?  Feel free to see the links in my "Downloads" page.

Jim
Jim United States
2/20/2009 9:04:24 PM #

The DetailedDownloadCounter.xml file does exist in the data folder and the folder does have all the wright permissions required.

Geert van Horrik
Geert van Horrik Netherlands
2/23/2009 8:48:20 AM #

I have absolutely no idea why the download counters are not working. I think it's best if you post this in the forum for BlogEngine.NET since this is not a problem of 1 single extension.

Jim
Jim United States
2/23/2009 3:19:29 PM #

I opened a discussion in the BlogEngine.Net Forum.

www.codeplex.com/.../View.aspx?ThreadId=48237

CudjoeBill
CudjoeBill United States
4/7/2009 3:57:17 PM #

Great extension. Thanks for sharing.

my tech addict
my tech addict
6/24/2009 7:03:57 AM #


I'm quite new to BlogEngine.NET. but what you write in this post is really good and very informative.
I think it will help me in the future. Thanks for the great work

Tukang Nggame
Tukang Nggame United States
6/27/2009 5:52:56 PM #

How do I use on wordpress because I'm currently using Wordpress for a few of my sites.

Geert
Geert
6/28/2009 7:45:05 AM #

This counter is for BlogEngine.NET only.

Pingbacks and trackbacks (6)+

Comments are closed

About the Author

Geert van Horrik is an independent freelance software developer since January 1st, 2007. Since then he was been working on several projects from C++ to C# (WPF, Silverlight, ASP.NET, etc). Currently he loves to write his software using WPF (or Silverlight if WPF isn't an option).

Lately, Geert is spending a lot of time on Catel, a free open-source MVVM Framework for WPF and Silverlight. Actually, it's more than "just" an MVVM Framework, it's a complete application library!