My home server BLEW UP and I have been down for a week. I did not want to loose my head along with my server so I took my sweet time to relaunch in style. I'm baaack. So much better site. There are a few more things to fix before done. So far so good. Take a look:

Comment unsuccessful. Please correct the errors below.

It’s alive! My site is Baack!

I’ve been running a server in my closet at home for years and years. Plus I have a 1GB Internet connection to my home (yes really). I have never felt the need to host outside of my closet. Yes – I’ve been closet hosting. Deep dark secret for a Windows Azure MVP. When my server went down so did the sites on it. My domain magnusmartensson.com went down as well. First I panicked. I have not been offline since… well… ever basically. After a while I calmed down and analyzed the situation: So I’m down. Big deal? What do I need to set it back up? Instead of loosing my head along with my server I set about fixing the problem. Here is my resurrection story!

Choose a Blog Engine

Over the years I’ve been using several blog engines. Way back when I hosted my blog at blog.noop.se but have subsequently moved to the more pro-league “ego site” magnusmartensson.com. This is now the fourth blog engine I’ve tried out. Always I’ve found each engine lacking in one way or another. You might think; well why not just sign up for a WordPress account or something? Well. That depends on how much ownership you want over your content. Scott Hanselman has put those thoughts down really well here: Your words are wasted

There are certain things that I’ve learned that I want from my blog engine if it’s going to suit my rather picky needs. Here are my criteria for a GOOD blog engine:

  • The source code – baby! I’m a developer and I want the source to the blog engine that I’m going to use so I’m able to go into the code and ‘fix’ stuff to my liking. Sure this is an extreme criteria 99.9995% of all bloggers out there would NOT care about this. I do.
  • Open source with an active community and current code base. This is more obscure. What I mean is that Open Source to the code of the blog engine ensures I can get it, tweak it, and reuse it anyway I please. An active community to push the engine forward is also pretty nice. You can get help if you get into a pickle and the engine probably will be pretty competent. That’s all good! The last part… current code base. I love the fact that I’ve found a blog engine that runs on ASP.NET MVC and that the code looks really easy to grasp when sifting through. I have already made several changes and it’s easy for me to find where to inject my code and personal ‘fixes’.

I found and fell for FunnelWeb blog engine which fills my basic criteria. There are more details on the features in that engine in the post below.

Given a good engine at the heart of things we can move on to:

Get full control of the blog entry addresses

Each blog engine has a Uri schema of it’s own. It can be with dates in the Uri and a nice pointless word like ‘archive’: weblogs.asp.net/scottgu/archive/2012/06/07/meet-the-new-windows-azure.aspx or with names of entries that are hard to read www.hanselman.com/blog/HelpYourUsersRecordAndReportBugsWithTheProblemStepsRecorder.aspx with an obscure number ayende.com/blog/159042/handling-entities-validations-in-ravendb or some other obscure number www.zdnet.com/microsoft-ceo-ballmer-devices-devices-devices-7000005507/. There are may formats. Each engine has it’s own ‘proprietary’ format. Some are good others are just really bad. Plus they all lock you in to using that particular blog engine for the rest of times.

My advice is this; Get an engine that will give you full control of the Uri for your posts. I have found one. When I write a post I can specify the Uri for the entry completely arbitrarily. It’s kind of like a wiki engine in that respect. This way I can use words in the entry Uri that are meaningful for the content. This will help with Search Engine Optimization SEO. Plus it ensures that you have not locked your self to one single engine. You control the Uris – you control the shape of your content.

With my new engine I can write “magnusmartensson.com/what /ever/uri-i-like” and that’s the Uri my page/blog entry will have. This is really cool and powerful.

‘Your’ brand matters

One itty bitty detail which is OH so important is that your readers will not generally surf to your site. At least your returning readers won’t. Searches will hit your site naturally and then, hopefully, you might get more new readers. Most of the reads you will get will be linked to your feed. The nature of your feed matters! I don’t mean weather it’s an Atom feed or an RSS feed. I mean, again, the Uri of your feed. Your domain is your brand and your feed needs to be your own property. This is the Uri subscribers will link to and if you some day want to change your feed.

Your feed can be someone elses: weblogs.asp.net/scottgu/rss.aspx – that’s not really good. The Gu does not own his feed. Asp.net does. Or you can use a super superior feed service like FeedBurner for your feed: feeds.feedburner.com/AyendeRahien but then FeedBurner owns your feed and also your subscribers. Or, actually Google owns them since they own FeedBurner. OR you can claim the uri to your own feed. That can be done using feedburner the right way with the ‘My Brand’ feature: feeds.hanselman.com/ScottHanselman.

The point is that Scott, and myself feeds.magnusmartensson.com/magnusmartensson, can do what ever we want with our feed should we ever want to change the hosting for it. I essence we can take five minutes and re-implement our feed using for instance SyndicationFeed and SyndicationItem and host that feed for free on Windows Azure Web Sites.

With the Blog Engine done, my blog entry Uris and feed Uri in check – what’s next? As you recall I said I have had several blog engines before and actually also several domains. I need some way to redirect old links to my new content format. Luckily there is a way to do that in the Internet Http Status Codes. No – not the I’m a teapot (Http 418) status. I’m talking about:

301 Moved Permanently

Google knows where my content is, or was. Bing knows where my content is, or was. My posts used to have the following Uri base: magnusmartensson.com/post/2012/09/29/CloudBurst2012-aftermath.aspx Now they have this kind of appearance: http://magnusmartensson.com/cloudburst2012-aftermath. The latter is so much nicer. Sure the Uri does not show the date. But do I really need that? And the .aspx extension that tells I’m hosted on an ASP.NET site – do I need that? No and no.

But wait: I have old Uris on the same site and I want to let humans and search engines know I have moved my stuff. Permanently.

Http response status code “301 Moved Permanently” is exactly what I need! :)

There are three things you need to do in order to redirect Uris on an ASP.NET MVC site to a new location:

1) Ignore the routes you don’t want your MVC engine to try to interpret.

2) Catch those same Uris in a custom HTTP Handler (by implementing the IHttpHandler interface.)

3) Redirect to the correct Uris using the 301 Moved Permanently Http Status Code in the response.

Here is how I did it:

1) Ignore:

I added this MVC .IgnoreRoute rule to my RouteCollection.

routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*-.*\.aspx(/.*)?" });

This will catch all .aspx pages - my old addresses on my old blog.

2) Catch:

<system.webServer>
    <handlers>
        <remove name="BlockViewHandler" />
        <add name="BlockViewHandler" path="*.aspx" verb="*" preCondition="integratedMode" type="NoopMan.Aspx301Handler, NoopMan" />
    </handlers>
</system.webServer>

This simple trick will redirect all calls to .aspx to my custom handler, Aspx301Handler

3) Redirect using 301 Moved Permanently:

private static void Repond301(HttpContext context, Uri redirectionUri)
{
    context.Response.StatusCode = (int)System.Net.HttpStatusCode.MovedPermanently;
    context.Response.Headers.Add("Location", redirectionUri.AbsoluteUri);
    context.Response.ContentType = "text/html";
    context.Response.Write(string.Format("<html><head><title>Moved</title></head><body><h1>Moved</h1><p>This page has moved to <a href=\"{0}\">/</a>.</p></body></html>", redirectionUri.AbsoluteUri));
    context.Response.End();
}

Finally, I have ignored the routes in MVC, I have caught the same routes in web.config and implemented my handler, now I can redirect properly using a standard 310 Moved Permanently response. When Google/Bing sees this they will update their entries and list my new Uris. If an old link leads to my old Uris they will be redirected by all browsers and land correctly on my new Uris.

Get better hosting: Enter Windows Azure Web Sites

Next step is to make sure the shameful single point of failure be eradicated for good! Enter Windows Azure Web Sites. With my domain now hosted in Windows Azure Web Sites I get:

  • Super easy and fast deployment using TFS (That’s Team Foundation Service not Team Foundation Server) of if I want with Git (or for that matter GitHub or CodePlex).
  • Resilience by the fact that if my hosting would ever go down, power outage in the Windows Azure Data Center node or human error or what ever, Windows Azure is smart enough to automatically stand up my service again.
  • Scaling – in my case down to a really cheap offering.
  • Custom ‘naked’ Domain Names: magnusmartensson.com
  • File stored redundantly and ‘for ever’ in a domain I control. (Read below.)
  • Full tooling support in my development IDE of choice Visual Studio.
  • Hosting for my SQL Data using Windows Azure SQL Database. Again resilient and redundant and frickin’ awesome! And I can manage this database service from inside SSMS.

Windows Azure Web Site for the engine

I host magnusmartensson.com on a Windows Azure Web Site. I use one single instance of size shared. Sure this means that I don’t have fail over. I can live with that small potential down time because it’s not a time critical high traffic blog. Sure this means my web site will be co-hosted with other web sites. Again I can live with it because it’s not a time critical high traffic blog.

magnusmartensson.com in the Windows Azure Web Sites management console.

Windows Azure Storage for your files

I have made a tweak to the MetaWebLog API implementation in FunnelWeb to map the upload Uris to my blog post media content to a custom domain name connected to a Windows Azure Storage Account so that my posts from Windows Live Writer will link media content properly. If you understand what I just wrote :) you know that’s really cool. If you don’t let me explain: I open up my blog post writer; Windows Live Writer, and write my blog post. I add images and other content to  the post in the editor. I hit publish. All my media content is uploaded and stored in Windows Azure Storage. The Uris returned use a custom domain name base for my file content. Look at where the images of this post are stored – they use files.magnusmartensson.com/site/ as a base. Before Live Writer commits my post to my domain it updates the Uris in the image tags in the post to reflect the correct location. Here is my storage account in Windows Azure: (Shown using Cloud Storage Studio from Cerebrata)

SNAGHTML8c8592

Windows Azure SQL Database for the data

FunnelWeb uses a SQL Database. I migrated it to a Windows Azure SQL Database. Here’s what it looks like to manage a WASD from the Windows Azure Portal.

SNAGHTMLb4f6f7

Hosting completeness

Using Windows Azure Web Sites, Storage and SQL Database for hosting my domain plays really well with my blog engine of choice and the technical setup I have selected and tweaked.

What’s next

Are we there yet? No.

I have only published the engine and configured it to work the way I like. I still need to

  • Migrate a lot of more data, files and blog entries, to my new domain. Right now I’ve only moved a few blog posts over. Many more, close to 300, to come.
  • Design the UI of my site.
  • Add some more pages to the site with information like an ‘About’ page and a contact page.

All of these things are not required to go live at this time. I will add it over the next few days to come.

Summary

So folks… I'm baaack! (Meaning my domain is back online.) It’s been a journey but I truly feel that I just took full control of my situation, that my domain is stronger than ever before, that I own and control my content and that the hosting of my content is über superior now compared to what it was before – thanks to Window Azure.

There are a more things to fix before I’m done and fully content. But now I feel I have a good start on a really nice blog engine and a great platform! My blog now has sharks with frickin’ lazers! Does yours?

Cheers,

Magnus

Posted by: Magnus Mårtensson
Last revised: 2012-10-10 10:18 History

No comments yet. Be the first!

Login in to comment!