Simple BlogEngine.NET Download Counter Extension

-   Feb 04, 2008 -   BlogEngine.NET -   ,

A few months back, I made a file download counter for my blog.  I've been planning to make it available forever and tonight I was asked for a copy of the code so I figured I might as well make it available to everyone.  It is not too exciting and could likely use some code cleanup, but here is what has been running on my blog and on the main BlogEngine.NET site for a while. The download counter is very simple.  It is all stored in a single cs file that you add to your App_Code\Extensions folder.  Once you place the file there, you are done and it will start recording file downloads that go through the BlogEngine.NET file handler.  It is important to note that I wrote it counts files downloaded through file handler and not just any file you link to.  If you upload files to BlogEngine.NET through the Admin panel, they are stored in the App_Data\files folder.  (Yes, you can add folders like Windows Live Writer does to organize things a bit, but I'm going to keep this explanation simple.)  When files are upload there, you can access them through the file handler with a link in this format: http://mysite.com/blog/file.axd?file=filename.ext For those unaware, if you upload a file while writing a post, it will make the correct link for you and you really don't need to worry about any of this. Ok, now that we have that explained, let me tell you a bit more about how this works.  Each time a file is served, an xml file is parsed.  (This xml will be created the first time a file is downloaded and be stored in your App_Data folder.  This will change in BlogEngine.NET 1.4 when this is provider based.)  It looks through it to see if the file downloaded is already there and if it is, it increments the download count.  If it is not in the file, it just adds it to the file with a count of 1. The site visitor will not see the count anywhere on the site, but once you login to your blog, you will see the download links with a file counter on them.  Here is a close up of the screen shot above.  This is what I saw when I logged in tonight.  If you go and check out the NonZero Theme post, you'll notice the link doesn't include the download count. This is just one download counter option for you.  Ruslan Tur has another download counter option available for you to check out as well.  I renamed my extension SimpleDownloadCounter so as not to conflict with Ruslan's fine counter. Download: SimpleDownloadCounter.zip

 5 Things I Love about BlogEngine.NET

-   Jan 09, 2008 -   BlogEngine.NET -   , , ,

While I've very biased, I do really like BlogEngine.NET.  It is a fine blog software and handles my simple blog well enough.  However, there are a few features that are extremely nice and I wanted to take a moment to highlight them and make sure you are taking advantage of them if you are a BlogEngine.NET user. 1. Extensions Rock When Mads Kristensen first introduced Extensions, I thought it was a cool idea, but I didn't really appreciate the power they could have on my blog.  Since almost everything the blog does has an event, it is so easy to extend the software to do whatever you can think for it to do.  Additionally, you can share that code with other BlogEngine.NET users or use extensions others have created to really enhance your blogging experience.  In the past few months, I've put together 2 extensions for my own use and have used a number of extensions that others have created and made available on the web.  (Yes, I'll likely be making my extensions available soon, but you'll have to wait until then to learn what they are.) If you haven't looked into them, check out this list of available extensions to get a taste of what they can do. 2. Complete Comment RSS While I don't have a ton of comments to deal with on this blog, I never really liked getting comment notification in my inbox.  I get enough emails and it just wasn't an ideal place for me to get notified of comments.  I was thrilled when BlogEngine.NET put together Site Wide Comment RSS.  By that, I mean one feed for all my comments.  Having it in my feed reader seems like the perfect place for them to be. In case you are unsure where this can be found, my comment feed is: http://www.nyveldt.com/blog/syndication.axd?comments=show BlogEngine.NET also supports individual post comment RSS and I love that too.  When I want to follow the feedback of something, I just add it to my reader.  It is awesome and is found in most blog systems. 3. Great Live Writer Support Windows Live Writer (or Live Writer as I think they are going by now) is a great tool for blogging and BlogEngine.NET has some great integration with it.  In each release of BlogEngine.NET, we've added more and more features that can be taken advantage of inside Live Writer.  Beyond the basics of writing posts, BlogEngine.NET even allows Live Writer to add new categories, handle tagging, add and edit pages, set slugs, and turn on/off comments.  Combine this with the great plug ins available for Live Writer and you've got a handy blogging tool. If you don't use Live Writer yet, you are really missing out. 4. Pages are first class citizens While a blog is typically made up of post, pages can be an incredibly handy thing to have.  In a personal blog like this one, it can make for a fine About me page, resume, or nice place for articles.  However, they can be used more extensively and there really is no reason not too.  They are not a side show in BlogEngine.NET. Pages can be set to be your front page and even link into related posts.  They are searchable and can really fill out your site nicely.  (While I don't use pages much in the blog, I do have a BE site that takes much better advantage of pages.) 5. Theming is very easy I've had a bunch of different blog systems over the years and I've done a little theme work in a few of them.  BlogEngine.NET is just so easy to use.  If you've had any experience working with ASP.NET (and I mean any) you can quickly figure out how to move things around and make them look more how you'd like.  If you are a bit more adventurous, you can convert a free template or even make your own theme without having a deep knowledge of BlogEngine.NET.  I remember being shocked that I was able to make my first BlogEngine.NET theme in a 2 hour window and it seemed I spent half that time making decisions on where I wanted items verses trying to figure out how to do it (and that was before I joined the dev team and had spent any time really looking through the code.) The next version of BlogEngine.NET will make customizations even easier, but if you've ever wanted a unique look for your blog, you own it to yourself to see how easy it really is now.  I made a theming screencast a while back that walk you through make one from scratch, talking through each step and it runs about 25 minutes.  If you start by copying an existing theme, you would likely cut your time in half.