Mobile Device Type Detection in Sitefinity

Posted by Community Admin on 04-Aug-2018 02:11

Mobile Device Type Detection in Sitefinity

All Replies

Posted by Community Admin on 18-Jun-2015 00:00

To make my responsive sites offer a better experience, I want to be able to detect the type of mobile device and make decisions. e.g. A tablet might be able to display something that a phone can't.

Obviously, browser agent sniffing is a nasty no-go, but the standard ASP.NET Request.Browser.IsMobileDevice property makes no distinction for the device type other than it's "mobile".

I'm interested in what others do, and whether anyone has experience with using 3rd party solutions with Sitefinity, such as 51Degrees - which is slick but involves extra $$.

Posted by Community Admin on 22-Jun-2015 00:00

Hi Mike,

You can try the approach discussed in that forum:

Svetoslav Manchev

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items

Posted by Community Admin on 22-Jun-2015 00:00


Funny you should say that, as I'm ​currently testing a piece of code I wrote, which is a slight modification to code I "borrowed" from the bottom of that forum thread

private static bool IsTablet(string userAgent, bool isMobile)
    var r = new Regex("Tablet|iPad|PlayBook|BB10|Z30|Nexus 10|Nexus 7|GT-P|SCH-I800|Xoom|Kindle|Silk|KFAPWI", RegexOptions.IgnoreCase);
    var isTablet = r.IsMatch(userAgent) && isMobile;
    return isTablet;

Called as:

IsTablet(Request.UserAgent, Request.Browser.IsMobileDevice);

This seems to work for common tablets, but I'm not so sure of the various convertables, and is obviously prone to being broken by the Mobile/Tablet market - where new devices appear at an alarming rate.

The 51Deg solution has some attractions in that is regularly updated (weekly) and more advanced in its agent-string analysis, but the downside is obviously the extra $$ (although not so bad if running multiple websites on the one host - sounds like I'm talking myself into it - LOL) and I am unsure if the httpHandler (which basically intercepts all requests) will interfere with Sitefinity.

This thread is closed