Tue Nov 16 2010

Last week I released a minor version of the Url Shortener Helper.  It also released with the WebMatrix B3.  You can download the latest package on the CodePlex Site.  Four things were introduced with this release.

1. Shorter Assembly Names.

I think the assembly names are now final.  The new assembly names are:

  • Microsoft.Web.Helpers.UrlShortener.dll
  • Microsoft.Web.Helpers.UrlShortener.Bitly.dll

2. Updated Namespaces.

These now reflect the assembly names but I am still not satisfied.  What I don't like right now is the helper class doesn't have a namespace.  Nice from the user perspective but collisions will end up occurring at some point. Secondly if I was to namespace the static helper class I would create my own collision since the name of the class is the same as the namespace ( at least when it would be namespaced ).  I honestly don't have the answer at this point.

3. Added a NuGet package.

I love NuGet. I am so excited this hit the streets.  I have created a NuGet package for easier distribution and installation.  This is the same package WebMatrix is already using.  This means you can actually install the helper from within WebMatrix.  I plan to also submit it to the real NuGet feed so you could use it in an MVC3 application as well.  If you browse to _admin of your WebMatrix site ( example. http://localhost:29455/_admin ) you will be prompted to create a password.  Once created you will see the Helpers listed in the official feed.  Down at the bottom you will see UrlShortener Helper.

SNAGHTML3500eb

Once installed a two things will happen. You will see the two assemblies dropped into the bin folder.  If a bin folder doesn't exist it will create one. Secondly it will drop a readme file at the root with the setting.  This is just pure laziness so you can copy the code from the readme.txt and paste it where necessary.  You can delete the file once your comfortable.

4. Added an overload to Shorten.

I realized that you might in fact want to override the Settings the helper was setup with at App_Start.  Given that you can now pass in the Settings object to the shorten method.  The current implementation works like this.

  • Add the following _using _statement, @using Microsoft.Web.Helpers.UrlShortener.Core;
  • Create the one off setting object. > @{

               dynamic settings = new Settings();
               settings.UserName = "YOUR USER NAME";
               settings.ApiKey = "YOUR API KEY";
    }

  • Call it. > @UrlShortener.Shorten(@"http://DeveloperSmackdown.com", settings)