Skip to main content

Hosting .NET MVC on RackspaceCloud Cloud Sites

Last week I deployed a pet project (pun intended) of mine Borrow a Pet to the RackspaceCloud Cloud Sites environment.

So far I’m very pleased with the performance of the site, however I thought I would highlight a few areas you need to be aware of when developing/deploying .NET MVC apps to the Cloud Sites environment as their documentation right now is fairly light.
It should be said that the 24/7 Support team are fantastic, however I found myself having to use them a bit too often for my liking.

The technologies/tools/components I used goes like this.

  • .NET MVC for the Presentation Layer
  • LINQ to Entities for the data layer
  • SQL Server 2008 Database
  • Third Party Google Maps Wrapper for GeoCoding
  • Unity for the IoC Container


Medium Trust
Believe it or not but in my eight or so years of .NET development I’ve never had to develop with Medium Trust in mind. Boy had I been spoilt. For more details on Medium Trust information go to the knowledge base.

IIS7 Integration Mode
By default sites created on IIS7 are set to Classic Mode which means that if your using the .NET MVC Framework your routing won’t work. All you need to do is use the Live Chat support and ask them to change it to Integration Mode, they do it pretty much instantly.

One of the requirements is to generate Thumbnails whenever an Image is uploaded, seems simple enough. RackspaceCloud advertise this component as being available. What they don’t do however is document that it DOES NOT work in the .NET environment and only works with Classic ASP.

I actually changed my Thumbnail Generation process to use this component on the understanding that it would work. You can imagine my reaction when I was told that this doesn’t work and that quote “if you recode in Classic ASP it will work”.

So rather than rewrite my clean, sexy Unit Testable MVC application I decided to just roll my own and go with the System.Drawing and System.Graphics libraries and it all works fine.

As I strictly practice TDD there was the need for an IoC Container to resolve any dependencies at runtime. I have religiously used Castle Windsor now for a couple of years. What I discovered however is that the Release Build of Castle Windsor does not work in a Medium Trust environment, there is a way to Rebuild the project however having tried to download the Castle source and build it before proved problematic. So I made the switch to Unity and all is well. So when choosing an IoC container make sure you use one which doesn’t use reflection internally.

This one is fairly simple, but you will need to impersonate your NT account (same as the FTP account ) if you plan on doing any System.IO operations. This can be set by adding the Identity element to your Web.Config

<system.web> <identity impersonate="true" userName="dfw\username" password="strongpassword"></identity> </system.web/>

There are some Rules around using the Cloud Site’s mail relays.
You can only send 25 emails at a time and no more than 250 messages in a 20 minute period. If you want to send more than this then you need to contact Rackspace.

As I use Google Apps for all my email, my MX records were pointing to Google’s servers. This isn’t a problem so long as you set up an email account via the Rackspace UI then use those credentials when specifying the Network Credentials in the Smtp object like below.

var smtpClient = new SmtpClient(host, port) { Credentials = new NetworkCredential(fromEmail, smtpPassword), DeliveryMethod = SmtpDeliveryMethod.Network, }; smtpClient.Send(mailMessage);

Your Smtp Host to use is and port 25 is fine.

The knowledge base lists all the mail servers available.

Third Party Libraries
One of the key features of the site is Location based personalization which provides content to users based on their geographical location. In order to achieve this I needed to GeoCode the User addresses at account creation time.

For this I used Geocoding-net which is an awesome C# wrapper for Google Maps, Virtual Earth and Yahoo Maps.

By default though it didn’t work in a partially trusted environment. Fortunately I was able to get the source and add the following attribute to AssemblyInfo.cs and this was enough to get it work.

[assembly: AllowPartiallyTrustedCallers]

When analysing third party components make sure they support Partially trusted and if not make sure you have access to the source code.

If you take note of these limitations/restriction and are still able to provide all the functionality of your application then the gains can be massive.

Overall the Cloud Sites model is very attractive and is more inline with Windows Azure. What Cloud Sites allows you to do is focus on features and not get bogged down with Server Administration, which I for one am no fan of.


  1. "It should be said that the 24/7 Support team are fantastic, however I found myself having to use them a bit too often for my liking."

    Man, you can say THAT again.

    I am on with the support team at LEAST twice a day, every day.

    ...and it's not because I'm a whiner. These are "site down" reports, and I have them just about daily with RackSpaceCloud.

    In my opinion, they are trying to grow FAR too quickly with their latest marketing blitz, and it is affecting the reliability of their entire network. Think about how many people are signing up with them each month (including you! lol).

    I also run a primarily Microsoft web site (with all sorts of technologies as part of that umbrella VS.NET, IIS, SQL Server, etc) and I've had literally 15 outages in the past 45 days. The site has been down for more than a WEEK at a time! To be fair, most of these were related to the same issue, which was described at the time as "we can't figure out what's going on".


    Anyway, as developers, we have our own work to do, and it doesn't need to be compounded by a host with questionable reliability.

    The site has been down due to connectivity issues, security issues, failing hardware, scheduled and unscheduled maintenance blackouts and "misbehaving nodes".

    Anyway, I am getting away from RackSpaceCloud as quickly as possible and moving to a dedicated server.

    Maybe now I can concentrate on my own code instead of doing tech support for RSC.

  2. Thanks Will. I ran into the same problem with the Geocoding-net and our Cloud Site with RackSpace. How were you able to get the source code and change the assembly? I can only seem to find the actual compiled DLL.

  3. The Source is hosted on Google Code and you can get a read-only copy from the SVN repository at

    I can send you the compiled DLL I use which is Medium-Trust ready if you'd like.

  4. Extremely useful information which you have shared here about Cloud Sites. This is a great way to enhance knowledge for us, and also beneficial for us. Thank you for sharing an article like this. Oracle Fusion Manufacturing online Training


Post a Comment

Popular posts from this blog

Freeing Disk Space on C:\ Windows Server 2008

  I just spent the last little while trying to clear space on our servers in order to install .NET 4.5 . Decided to post so my future self can find the information when I next have to do this. I performed all the usual tasks: Deleting any files/folders from C:\windows\temp and C:\Users\%UserName%\AppData\Local\Temp Delete all EventViewer logs Save to another Disk if you want to keep them Remove any unused programs, e.g. Firefox Remove anything in C:\inetpub\logs Remove any file/folders C:\Windows\System32\LogFiles Remove any file/folders from C:\Users\%UserName%\Downloads Remove any file/folders able to be removed from C:\Users\%UserName%\Desktop Remove any file/folders able to be removed from C:\Users\%UserName%\My Documents Stop Windows Update service and remove all files/folders from C:\Windows\SoftwareDistribution Deleting an Event Logs Run COMPCLN.exe Move the Virtual Memory file to another disk However this wasn’t enough & I found the most space was

3 Reasons Why Progressive Web Apps (PWAs) Won’t Replace Native Apps

Many people believe Progressive Web Apps (PWAs) are the future of the mobile web, but in my opinion, PWAs are not a replacement for native mobile apps. Here are three reasons why: 1. Native mobile apps provide a smoother & faster experience  Mobile websites, progressive or otherwise are slower and not as smooth. 90% of the time spent is spent using apps vs the browser . The single most significant contributing factor to a smooth experience on mobile is the speed of the network and latency of the data downloaded and uploaded. When you visit websites on desktop or mobile, there is a lot of third-party code/data that gets downloaded to your device, which more often than not has zero impact on the user experience. This includes: CSS (Cascading Style Sheets) JavaScript Ad network code Facebook tracking code Google tracking code The median number of requests a mobile website makes is a shocking  69 . On the other hand, native apps only get the data that is requi

CPF Contribution Rates for new Singapore Permanent Residents (SPR’s)

Recently my wife and I applied and got approved for Singapore Permanent Residency. After completing the formalities the most significant immediate change is the contribution to CPF which is Singapore’s mandatory social security savings scheme requiring contributions from employers and employees. CPF contributions start from the date you obtain SPR status, which is the date of the entry permit.   Being a relentless budgeter I needed to know exactly how much I and my employer would have to contribute so that I could adjust my budget accordingly as the employee contributions get deducted from the monthly salary. After doing some research I discovered that there is a “graduated” approach to CPF contributions for new SPR’s where the contributions gradually increase in the first and second year and then upon reaching the third year are at the full amount. Note: There is an option for employers to contribute the full amount for year 1 and year 2 and the employee can use the graduated ra