ASP.NET MVC3 on Rackspace Cloud Sites

Posted on Feb 2, 2012 | 0 comments

Rackspace Cloud Sites  Webpage Redirect Loop

Https Issues

Launching an ASP.NET MVC3 site on Rackspace Cloud Sites has been mostly easy. Mostly. There are a few ‘gotchas’ that make it painful. There’s no need for you to waste time I’ve already spent figuring this stuff out so here’s what I’ve learned the hard way.

ASP.NET 4.0 isn’t the Default

You’ll see this manifest itself with an ugly configuration error when you try to visit your site. This one is easily fixed, just open a ticket or start a chat and ask them to move your site to ASP.NET 4.0. It takes them about 10 minutes if you ask via chat.

You Must Do an MVC Bin Deploy

Another ugly configuration error will happen when you try to visit your site. Luckily, VS2010 has added a feature specifically for including the MVC deployable assemblies. Right click on the project and select ‘Add Deployable Assemblies’ and you’ll see the dialog. If you have any problems, follow the instructions in this article. Phil did a great job writing that up so I don’t feel the need to repeat it.

Get the User’s IP Address

This was another fun one. I kept trying to use Request.ServerVariables[“REMOTE_ADDR”] or Request.ServerVariables[“X_FORWARDED_FOR”]. Neither worked. Finally, I wrote a little method that looped through all the variables on the server and found the one that worked.

Request.ServerVariables[“HTTP_X_CLUSTER_CLIENT_IP”] is the one you want to use to get the client’s IP address.

Email Limits

I didn’t read the Acceptable Use Policy closely enough to see that there are limits of 5,000 emails per day and 250 per 20 minutes. I found that out the hard way when I launched something that generated lot of confirmation and welcome emails. Enough to break that AUP. That night, I answered a LOT of support tickets from unhappy customers and eventually took out the account confirmation until the traffic died down. Live, learn and use Sendgrid.  Rackspace Cloud Sites has a special deal set up with Sendgrid for 40,000 emails per month. Use it. Sendgrid takes about 24 hours to get all set up and provisioned but it’s worth it. The email insight is very helpful and you can see who’s blocked you and get all that sorted out.

Get HTTPS Working

The first thing you need to do is install your certificate. This is pretty straightforward in your admin area. Click the security tab for your domain and follow the instructions.

Then it gets tricky. I naively thought that simply adding the [RequireHttps] attribute would work. Boy, was I wrong.  I keep getting This webpage has a redirect loop” error in Google Chrome or “Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”  in Firefox. Some googling led me to figure out that it has something to do with proxy servers but nothing on how to fix it.

After much searching, I finally found an article on Rackspace’s Knowledge Base, How to Force SSL on My ASP.NET Cloud Sites article. I tried to follow the third set of instructions for MVC3 to be able to use the [RequireHttps] attribute. That failed miserably and I was still getting redirect errors.

So, of course I start up a chat with the usually very helpful Rackspace. This time, not so helpful. The first help desk person I got that thought code went in the web.config file. Um, wrong. It took me a while to figure out that’s what he thought. Once I asked for someone else, I got it resolved quickly.

Here’s How to Get it Working

Use the first set of instructions and include the web.config code from the knowlegebase article. In my VS2010, it shows this as an error but do it anyway. Then remove any [RequireHttps] attribute that you had in your code. This will force your entire site into Https. I still haven’t figured out how to only do certain parts in https. For now, I’m fine with that but if you know a solution, please leave it in the comments.


Hope this helped you deploy your ASP.NET MVC3 site on Rackspace Clouds. If you have any other tips, please add them in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *