Introducing, Powered By Twilio & AppHarbor


A few weeks ago a challenge came across my Twitter stream – build an application that combines Twilio, a cloud communication platform, with AppHarbor, the easiest way to deploy and host .NET applications. This seemed like the perfect fit for an idea that’d been bouncing around in my head for some time. Five days later,  long after the Super Bowl ended, I submitted my entry.

Yesterday morning another tweet popped up on my desktop…my entry won!

And now…I’m proud to introduce – a simple tool to manage your Netflix queue.

The Idea

How many times have you been away from a computer and thought of a movie you don’t want to miss? This is where comes in – if you can send a text message, you can add movies to your Netflix queue. There are existing applications to accomplish this, but sending a text message is faster, and you don’t need a smart phone.

The Implementation

When you sign up for, your Netflix account is linked to your cell phone, and you’re given a phone number to send movie titles to. This number is provided by Twilio and it’s where the magic begins.

When Twilio receives a text message, it sends the information on to the web application, which is running ASP.NET MVC 3. In there is a single endpoint that receives the message, looks up your Netflix account information, takes care of business, and responds with a text message to let you know the movie was added to your queue.

MVC’s model binding turns all the parameters Twilio sends into an easy to use class. To respond to the incoming message there are two options – TwiML or REST. The former is the only option if you want to do more than one action, like send multiple SMS messages and redirect to another TwiML document. The later is the easier option when you just want to send a response – set your response’s content type to text/plain and Twilio will send the response body to the sender as an SMS message!

This was the approach used by A custom SmsResult sets the content type and makes sure that the message doesn’t exceed 160 characters. If you don’t want to send a reply message simply send an empty response.

It’s also important to handle any errors properly so that Twilio always gets a valid response from your application. MVC makes this crazy easy without needing to wrap your entire action in a try/catch. By either overloading the OnException method or providing a custom filter to the action or controller you can return an SmsResult no matter what happens during the action.

Security & Privacy

We are all concerned about privacy, so handling phone numbers should not be taken lightly. Even in a simple application like this I want to take every precaution to keep users’ phone numbers safe.

The first, and most effective, precaution is does not store the full phone numbers. Because will always be responding to incoming messages, it will store a hash of the phone number and the last four digits and still be able to link your Netflix account to your incoming movie request.

The second way to protect the Twilio endpoint is to ensure that will respond to requests from Twilio and nobody else. In every request, Twilio will sign the request using your secret authentication token and send it in a HTTP header. To validate it you perform the same operation and if the request is valid you will get the exact same value.

The following is an example of how you can create an action filter in MVC to easily validate an action or every action in a controller. It’s based on John Sheehan’s most excellent presentation at mvcConf last week.

One thing to note here is that when you are in a load-balanced environment like AppHarbor the web server your request is being served by is likely not the exact address that Twilio calls from the outside. Since it is part of the signature we need to be sure to use the host header value and not the raw URL as seen by ASP.NET.

Couldn’t Be Easier

In I’m barely scratching the surface of Twilio’s capabilities. In addition to sending and receiving SMS messages, they have an incredibly powerful platform for making and receiving phone calls. Best of all it’s available on a pay as you go basis – no contracts! You no longer need to be a Twitter-sized company to be able to add phone and SMS capabilities to your application.

Go ahead and try it out for yourself – you get $30 worth of credits just for signing up!

Moving On Up To The Cloud

For the last year I’ve been hosting this site on a server running in my basement. While it’s been a much better experience than the $6/month, ‘everything included’, shared hosting plan I was on before, this setup has had its own set of problems. For starters, cable internet is not a viable way to host web sites. Even with a commercial grade, unshared, 10/1Mbps connection the response time to my site was quite high and fluctuated wildly. To make matters worse, we apparently live in a neighborhood that doesn’t have much redundancy on the local power grid – we’ve have numerous power outages in the year we’ve lived here.

While this might be acceptable for a simple blog, I recently started hosting a few sites for others, including our local .NET Users Group and a neighbor’s business site, and the performance and uptime bar needed to be cranked up a bit. I needed something that was on a good, solid internet connection, gave me plenty of control, and was priced low enough to address the wife acceptance factor.

My new home: The Rackspace Cloud

After considering a variety of options, I finally settled on Rackspace’s Cloud Servers. I’d been tinkering with their services for some time and had been very impressed not only by the performance and capabilities, but by the price. For as little as $11 per month you can run your very own virtual Linux server with 256MB of RAM and 10GB of disk space. Need Windows servers? They start at about $29 per month for 512MB of RAM and 20GB of disk space. Need some short-term servers to handle capacity? You pay by the hour and there are no minimums or commitments! Their control panel is incredibly easy to use, and for more advanced scenarios there’s even an API for automatically scaling up and down. I could go on, but instead I’m going to recommend an excellent review at Social Cloud Now.

For my little setup I went with 2 Ubuntu servers and 1 Windows server – total damage is just over $50/month. This gives me an Apache web server, an IIS web server, and keep the database on its own machine. How does it perform? I think my Pingdom response time report says it all.


Moving up to the Rackspace cloud has cut my response time in half! Before the move my response time averaged close to 800ms, after it’s under 400ms (the brief spike was after I had migrated the database to the cloud but before I had migrated the web server). Those are the worldwide numbers – the US average is only 170ms!

A perfect fit

I couldn’t be happier with my move to the Rackspace cloud. Having great performance and availability, being easy to use, and affordably priced makes Rackspace my cloud provider of choice.

in Blog | 468 Words

Speed Up The ASP.NET Development Server

Visual Studio has had a built-in web server for years, but I’m apparently one of the few developers that still prefers IIS. Why? It’s certainly not more convenient – you have to setup a virtual directory, file system permissions, and change the debugging options. It’s because on a modern Windows OS (Vista or newer) it is so slooooooooow!

Take a look at the following Firebug stats:


There is literally no content on this page yet. I’ve got two static resources coming from the site, and I’m using the Google AJAX loader to pull in jQuery and the Maps API. Yet while even the slowest resource from Google takes a scant 144ms to load, the page and resources I’m pulling from my local machine are each taking just over a second!

Further testing showed that where Firefox and Chrome both exhibit this behavior, IE8 did not (or at least not by my seat-of-the-pants testing – the IE developer tools still don’t have a network profiler). Even stranger is that if I connect using or localhost. (notice the trailing .) things improved!

Something isn’t right here.

The Culprit: IPv6 and DNS

With Windows Vista, Microsoft included the IPv6 networking stack by default. Under Windows 7 (and probably Vista) they’ve apparently left resolution of localhost up to DNS. As far as I can tell the slowness isn’t the browsers’ fault, but rather the system trying to resolve localhost using IPv6.

Fortunately the fix is easy. Fire up Notepad (or your text editor of choice) as an Administrator, and open up your system’s hosts file (typically C:WindowsSystem32driversetchosts). You should see that all entries are commented out. Simply uncomment (remove the #) from the IPv4 localhost entry only, save the file, and restart your browser.


Once this is done, things look much, much better when using Visual Studio’s development server. As we’d expect, the local resources are significantly faster than the external ones.


in Blog | 317 Words

Don’t Get Mad, Get Better

I had seen this flash by yesterday, but today the story has hit mainstream. Apparently at yesterday’s Microsoft company meeting Steve Ballmer tormented an employee who was brandishing an iPhone. Should that employee have been a little more discreet in Ballmer’s presence? Maybe. Did Ballmer overreact? Probably. Should employees feel pressured to use only their company’s products? Absolutely not. Their company should make products that their employees want to use!

Don’t get caught with your pants down

Full disclosure: I am a BlackBerry user on Verizon. I live in Montana, where AT&T just doesn’t exist. Maybe they think there’s nothing here but cows?

In 2007 Apple turned the mobile industry upside-down when it introduced the iPhone. Never before had any phone offered so many easy to use features to consumers, and we ate it up. Before the iPhone smart phones were pretty much exclusively for business people and choices were limited, Windows Mobile or BlackBerry. Within months we were seeing phones being touted as iPhone ‘killers’, but that was far, far, far from reality.

More than two years have passed and there still isn’t anything even close. Many have tried and fallen short. Some of those have actually been really good phones, but still no iPhone. Why not? I’m certain that there are lots of incredibly smart people working at Nokia, LG, HTC, etc. We have Windows Mobile and Android operating systems that can run on many devices. How is it that the iPhone has gone so long unchallenged? Surely those in the mobile industry had known that something was coming from Apple, even if they didn’t know what. Yet that sat idly by churning out one generic phone after another. They had become complacent. A newcomer to the industry couldn’t possibly offer any significant competition, right?

Wrong. Apple has claimed about 13% of the smart phone market in just over two years, while Microsoft’s is sliding down past 9%.

You can’t really blame Ballmer for disliking the iPhone so much. Apple’s success has come at the expense of Microsoft and others, who were now scrambling to get something to market as quickly as possible. This marked the beginning of the cycles where just as soon as anyone gets remotely close to a comparable device Apple would release a new iPhone.

It didn’t take long to see that the iPhone was going to start running away with the market. At its launch it was the most expensive mobile device you could buy, but that didn’t stop thousands of people from camping out to get one. The day Steve Jobs announced the iPhone the Windows Mobile team should have put everything on hold to start planning its return strike. Each and every one of them should have been in those lines to get an iPhone so that they could really understand what made it so great. Only then could they really design a device worthy to be called a competitor. But they didn’t, and now they are playing catch-up.

Never stop getting better

This story applies to a broad range of industries, with software development absolutely being one of them. It’s relatively easy and inexpensive to take an idea and turn it into’s one of the reasons I enjoy what I do so much. But in an industry that can move so quickly you simply can not afford to let your guard down. To stay in the lead you’ve got to innovate in your product, or someone else will. If you become complacent you will get overtaken. And in the event that you do get your ass handed to you, don’t even think about getting mad.just get better.

in Blog | 609 Words

Setting Up Google Analytics For Your Bitbucket Repositories

One cool feature of Bitbucket is the ability to track traffic to your repositories using Google Analytics. Setting it up is simple, but there are a few subtle tricks. Here’s how to do it.

  1. From your main Google Analytics screen, click “Add Website Profile” at the bottom of the screen.
  2. If this is the first repository you’ve setup, select the option to add a profile for a new domain. Once you’ve done this for one of your repositories you can use the existing domain option.
  3. In the URL field, enter “”.it won’t let you enter the full URL of your repository here.
  4. Click “Finish”, which should take you back to the main Google Analytics screen.
  5. Find your analytics key for Bitbucket (i.e. UA-123456-7) and copy it.
  6. Go to the “Admin” page of your repository and paste the analytics key in the appropriate field.
  7. Head back to Google Analytics and click “Edit” on your newly created profile to bring up its settings.
  8. Under the “Main Website Profile” click “Edit” and paste the full URL of the repository in the “Website URL” field.
  9. It might take a few minutes, but the status of the tracking code should change from “Tracking Unknown” to “Waiting for Data”, and eventually to “Receiving Data”.

Now you are able to have some valuable insight into traffic reaching your repositories!

in Blog | 227 Words

WordPress Gotcha: Upload Path After Migration

I recently moved a few web sites running WordPress from an Ubuntu host to a Windows Server 2008 host and have spent the last few hours trying to figure out why I couldn’t upload pictures through Windows Live Writer. Once I got past a recent upgrade bug everything seemed to be working except the files weren’t being written to disk.

Out of sheer desperation I came across the following options screen.


See the issue?

Turns out that at some point WordPress wrote the full *nix path to that option and didn’t error when it couldn’t find the path!

in Blog | 97 Words

Azure Presentation

As promised, here is my presentation deck and demo code from last night’s user group meeting. Thank you to everyone who was able to make it!

The other note I wanted to add was the link that I was unable to remember last night in reference to denormalized data in the cloud.CAP Theorem.

Azure Presentation – [Download]
Azure Demos – [Download]

in Blog | 62 Words

Make Existing Projects Run in Azure

Disclaimer: This is not a tutorial on how to take an existing project and make it ‘just work’ in Azure. Depending on your existing project it may either be as easy as described below, or so painful that it’s not worth it. The goal of this post is simply to show how to make projects compatible with the Azure development fabric.

So you’ve got an existing project and are experimenting with making it run on the Azure platform. Do you.

A) Create new Azure projects and meticulously copy your code over?

B) Throw your hands up in defeat and tell your boss it’s too much work?

C) Add a few snippets of code to your existing projects and be a hero?

As it turns out, C is the correct answer! In the case of either a web application or a class library, you can easily turn them into web roles and worker roles, respectively. In order to do this, simply unload the project and add the appropriate XML to the project.

To make a web application project (including ASP.NET MVC) able to run as a web role, add the following.

.csharpcode, .csharpcode pre
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
background-color: #f4f4f4;
width: 100%;
margin: 0em;
.csharpcode .lnum { color: #606060; }

To make a class library project able to run as a worker role add the following.

.csharpcode, .csharpcode pre
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
background-color: #f4f4f4;
width: 100%;
margin: 0em;
.csharpcode .lnum { color: #606060; }

Once you’ve made these changes and reloaded the project, you should be able to associate your cloud service project with an existing web or worker role!

Unload Project

Unload Project

Edit Project

Edit Project

Editing Project


Reload Project

Reload Project

Associate Role

Associate Project

A Few More Tricks

Copy LocalAs I was working on this post I came across a few more tricks and undocumented nuances that cost me an unfortunate amount of time trying to figure out.

  • In order to run an ASP.NET MVC application under Azure, you’ll need to copy the System.Web.Mvc assembly local. This can easily be accomplished from the properties pane.
  • In web applications, you can not work with the RoleManager within Application_Start (see the remarks after the jump).
  • While you can make any class library a worker role, the development fabric will crash & burn if you do not have exactly one class in that assembly the derives from RoleEntryPoint.
in Blog | 545 Words

Windows 7 Beta – First Impressions

This weekend I wiped my system, and installed the freshly released beta of Windows 7 x64!


Why not? 🙂 In hindsight, it may have been a bit irrational given that prior to today this system has been the most solid, stable, and enjoyable system I’ve ever worked with. I had been running Vista Ultimate x64, my very first daily-use Vista install, on fairly decent hardware for well over a year. It’s actually been so long since I’ve reinstalled the OS on my daily-use PC I completely spaced deauthorizing iTunes!

So what prompted the reinstall? After acquiring a copy of the PDC build, I installed it in VirtualBox, and the performance was unbelievable! Having experienced Vista in both the virtual and physical worlds, I’ve always felt like it depends on the Aero UI to feel snappy…it just didn’t feel quite as fast when virtualized or not using Aero. Yet this build of Windows 7 in its pre-beta state ran fast virtualized!

How’d It Go?

For the most part the experience has been pretty good. The install seemed to take an unusually long time compared to Vista…almost felt like the hardware wasn’t detected properly and hence not running at its best. This seems a bit strange since I’m running year old, fairly generic hardware. Unfortunately once I got to installing drivers, I found that the Intel chipset driver installation utility wouldn’t run due to ‘an incompatible OS’…I had to extract the zip file and manually install the drivers. Hopefully with the beta of Windows 7 publicly available Intel will update their driver package. The other hardware-related comment is that NVidia has Windows 7-specific drivers available through Windows Update.

Stability and performance have been nearly what I expected. Memory usage seems lower, and boot time seems faster. That being said, it hasn’t been a completely smooth experience.

  • When the system went to sleep for the first time it didn’t want to wake back up.
  • Connecting to Windows 7 via remote desktop is really, really slow and choppy, even on a fast LAN.


For the most part the applications I use regularly installed and run fine. This includes Firefox 3, Foxit Reader 3, 7-Zip, BlackBerry Desktop, Launchy, Notepad++, Quicken 2009, TweetDeck, and the Windows Live applications. Both Silverlight and Flash run without any issues. For ISO mounting Virtual Clone Drive installed and works fine, and for antivirus I installed the free version of Avast! antivirus. All of my programming tools installed and run just fine – Visual Studio 2008, SQL Server Express, Tortoise SVN, ReSharper, & Visual SVN.

  • iTunes: This was by far the most frustrating part of this whole experience. The installer would continually hang after installing everything else included (QuickTime, Bonjour, etc.) but before iTunes. I finally got it to work by extracting the contents of the downloaded setup file, which contains the installation packages for the individual applications, and using the iTunes installer from there.
  • Google Chrome: Installed fine, but wouldn’t load any web pages. A simple Google search via Firefox brought me to a working solution. Turns out its an issue specific to the x64 version of Windows 7.
  • Skype: The latest beta of Skype 4 installs and runs fine…until you try to shut it down. If you log off, restart, or shut down with Skype running, it will crash, and sometimes Windows will prompt you that it can’t restart until Skype exits. Even if you close Skype by itself it occasionally crashes.

The New Taskbar

One of the most visible changes to Windows 7 is the new taskbar. For an excellent look at the new taskbar, as well as some of its issues, I recommend taking a look at Paul Thurrott’s Simple vs. Easy article. While there are definitely some strange usability issues with the new taskbar, I think Microsoft is very, very close to something very slick. I agree with Paul that in the default mode of ‘always combine taskbar buttons’ it isn’t entirely clear what is running, and that the ‘combine when full’ is more ideal. But that still doesn’t address the launching of new instances, which leads to the jump lists. I had found the jump list on my own via the right-click, but the click, hold, & drag up technique almost feels better.

One feature that Paul didn’t address in this context is what happens when you hold over one of the running applications. After a second or two, you get a little mini-view of the window…same as Vista. But if you hold over the mini-view, all the windows on your desktop become transparent except for the one you are hovering over!

Taskbar Hover

This, I believe, is the connection that has yet to be made…and Microsoft is so close! Paul points out that the taskbar was originally conceived address the problem of users ‘loosing’ open windows on the desktop – I problem that I often have as a developer who often times has many, many windows open at a time. In Vista, in addition to the taskbar and mini-views, you could also use the alt-tab, which shows only the icons and part of the window title, or the new win-tab, flip-3D eye candy, that does show the whole window, but at an angle. None of these things, however, work nearly as well as the hiding of all windows except one technique!

Think about it; they’ve got the new taskbar, and they’ve got this new hover behavior…how easy would it be to reduce the steps between mousing over the taskbar and simply hiding everything but what you are hovering over! Don’t flip it at an angle for the sake of eye candy…just show it, as is, by hiding everything else!

Final Thoughts

Overall I think this was a good thing. It gives me a chance to play with the latest and greatest, and it only cost me one authorized iTunes computer! Vista introduced the consumer to 64-bit computing, and over the last few years there have been many positive steps towards making hardware and software more compatible. Yet despite the state of Windows 7, most of the issues I encountered have been related to being an x64 OS.

That being said, I’m really excited for Windows 7. It is pretty much what Vista, an OS I very much enjoy using, that has been polished & refined. It’s already excellent performance is most certainly going to improve, applications and drivers will be updated (Intel and Apple, I’m looking at you!), and hopefully we’ll see some improvements to the taskbar, too.

in Blog | 1,143 Words