Using the ConfigurationManager to Access your ConnecitonStrings in the Web.Config

This is just a quick post because I couldn't find this information easily available on other sites. I knew there was a quick way to access the connection strings from the web.config file (and other app settings) without going through some crazy XML reader or doing something ridiculous like what http://msdn.microsoft.com/en-us/library/ms178411.aspx. I'm sure this is on the internet somewhere, but the more places the better as far as I'm concerned.

If you simply add the System.Configuration to your 'using' list you can use the ConfigurationManager class which exposes the AppSettings and ConnectionStrings easily. In this way you can access the ConnectionString from this single line instead of the block of ugliness MSDN suggests.

ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString

Oh, by the way, this is the MSDN madness:-)

System.Configuration.Configuration rootWebConfig =
    System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot");
System.Configuration.ConnectionStringSettings connString;
if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
{
    connString =
        rootWebConfig.ConnectionStrings.ConnectionStrings["NorthwindConnectionString"];
    if (connString != null)
        Console.WriteLine("Northwind connection string = \"{0}\"",
            connString.ConnectionString);
    else
        Console.WriteLine("No Northwind connection string");
}

New WikiRater Features

I've been working to add a few more features for WikiRater that I think are really cool. The one that I've had the most fun with so far is the "Trending Article" page. This page shows articles that are being rated right now. It works pretty similarly to reddit or hacker news, if you're familiar with them.

The other fun feature is the Random Interesting Article. This will find an article with an average rating of 8 or higher. If you're logged in it'll make sure you don't get an article you've already rated.

Finally if you're logged in and browse to your User Page you can see a list of all the articles you've rated, and what you rated them. This is a nice feature if you want to try to track down that elusive "Alphabetizer" or "Nice Distribution" achievement.

I'm going to write a follow up post on the inner workings of these features, but for now. If you haven't already go sign up and check out the cool new features!

WikiRater is Now Live!

Screenshot
I'm excited to announce my project, WikiRater, is now live and ready for your participation! WikiRater started out as my attempt at creating an algorithm to rate Wikipedia articles. I wanted to be able to find random interesting articles, but discovered my program lacked a key component: Your input.
I designed WikiRater to be as easy and fun as reading and rating Wikpedia articles can be. Just install the bookmarklet, then when you're browsing a Wikipedia article just click the bookmarklet and rate the article (it only take a couple seconds, and after you rate you can see what my program would have rated it!).
There is a ton more information on the WikiRater website (http://wikirater.whoisjoe.com/) so go check it out, register and participate and tell your friends!
I've also added a bunch of other fun features like Leaderboards and point systems (see how you rank compared to the other WikiRaters!), Accomplishments (Gain extra points for rating articles!) and User Pages (see the Accomplishments, points and other information about you and other WikiRaters!).
I hope you'll participate, I think it'll be fun, and if you find bugs or have any requests for features please let me know!