Martin Abrahams Team : Web Development Tags : Mobile Web Mobile redirects with 51 Degrees

Martin Abrahams Team : Web Development Tags : Mobile Web

The days of building a mobile version of your site for the sake of jumping on the bandwagon are long gone. Mobile devices users make up a serious percentage of online traffic and it's now a real world requirement to provide a quality experience to mobile users.

The decision which needs to be made at a high level is to decide whether to tailor your existing site for mobile devices or to split the mobile site off into its own project. Up until recently mobile devices were far more restricted by bandwidth and support for common browser tech such as JavaScript and AJAX support, so the choice to split the mobile site out to a standalone platform with limited content was a no brainer.

Now with 4G connectivity and comparable rendering to the mainstream desktop browsers the decision is a much harder one. The governing factor would ultimately come down to what percentage of the desktop website's features and content needs to be available to mobile users.

Regardless of which way you go, you are still faced with the same issue that's plagued mobile site developers since the beginning - understanding the capabilities of the mobile device. While allot more devices now share common rendering engines and screen sizes, the recent explosion of the tablet market and web enabled gaming consoles has reintroduced the problem again. There's no one size fits all anymore. One common scenario is to render the desktop experience for tablets and other large screen devices and only redirect actual phones to the mobile site.

The process of actually dealing with this by hand is far more complicated than it initially seems. version 2 shipped with a feature known as Browser Capabilities which allowed for dead simple server side detection of browsers and support for features.

The problem which became apparent very quickly was that the browser definitions file was simply not maintained by Microsoft therefore rendering it virtually useless. You'd go out and buy the latest and greatest web enabled smart phone and navigate to your site and find yourself at your desktop site.

Fast forward to today and .net 4 has an evolution of the Browser Capabilities system, albeit with a slightly less out of date definition file. There are a number of community projects which provide up to date browser definition files but they still don't provide the generalised grouping that's needed to implement common rules, remembering that in this context basically anything that’s not running a proper desktop OS and web browser is treated as a mobile device.

This is where we've discovered a great .net component called 51 Degrees ( It's designed to take the headache out of the detection and redirection process by grouping the devices logically using flags such as IsTablet, IsSmartPhone, IsSmallScreen etc.

This allows you to then create simple, shared redirection rules based on combinations of these properties. 51 Degrees provides a free version as well, however it's missing the flags which I just listed. It's still very good if you’re looking for updated definitions and are happy to treat all non desktop browser's as mobiles.

Here's an example of a set of rewrite rules which I've recently defined for a project. In this case we're using the premium datafile and redirecting mobile traffic off to the equivalent page on a separate mobile site.

We are redirecting all mobile devices which aren't tablets to the mobile site.


Also note the firstRequestOnly attribute on the second line, this tells the system to only redirect users to the mobile site the first time (per browsing session), so that if the user was to re-enter the desktop URL into their browser they would see the desktop site rather than being bounced back into the mobile site a second time, since it's assumed that this is what the user is trying to achieve.

This is a great example of a pitfall that you'd come across developing a custom solution. I'm very pleased with this product since it's a non invasive solution to mobile detection and redirection which leaves us to focus on what type of device to send where as opposed to worrying about the devices on a product/model level. Of course this can still be done if required, but in practise I've found the grouping the best way to go and is true benefit of this product.