devXero's blog

a blog about agile, development, and automation

Posts Tagged ‘Browser Sniffing’

Mobile Browser Sniffing

Posted by Mike Longin on August 10, 2010

For my internal site, I wanted to give it the ability to display an version specific for mobile browsers. To do this required the ability to sniff our a mobile browser. Initially I was using the provided .Net command for verifying if the accessing browser was a mobile browser.

Request.Browser.IsMobileDevice

However while this works great for the iPhone this did not work at all for Android based devices. After a large amount of searching I found the MobileESP open source project (http://code.google.com/p/mobileesp/) for determining if a browser is from a mobile device. Initially I used thier entire code base. However I felt that solution was too bulky and I ended up just finding the code for locating an Android based device and using that instead.

Request.UserAgent.ToLower().IndexOf("android") != -1

Even if you do not need their entire code base, the project is a great repository for determining how to identify any mobile based browser

Advertisements

Posted in Uncategorized | Tagged: , , , , , | Leave a Comment »