Today I'm using two mobile devices: The BlackBerry Perl 8130 and
the BlackBerry 8830 'World Edition' phones by Verizion. The 8830 is
larger but has a qwerty keyboard. If I'm actually going to be sending
email from something, this is the choice. For being in touch when on
the go (and I don't like to carry lots of stuff) the Perl is good. But
when I'm on the train or bored waiting for something, I like to use my
Perl to access some websites, especially my own.
Both phones come with Research In Motion (RIM)'s built in
browser. It supports images but it's definitely a mobile browser. It
is designed to display content that fits well on a phone screen. This
is a great interface for getting information quickly from mobile
optimized websites. However, since mobile phones have limited screen
sizes and capabilities, a lot of what your website has to offer just
isn't good in that environment. Opera Mini
is great, it runs on both devices (and many other compatible devices)
and shows you the full web page, which it shrinks down to fit your
screen. You can zoom in on any part of the page and interact with
content that doesn't have special mobile-enabled programming.
Mobile phone bandwidth is increasing all the time, and mobile
device web browsers keep improving, but you don't want to serve full
javascript enabled, multi-media data to a mobile device; it's too slow,
and many features won't work. You know this, which is why you're
reading this blog post. So if you are an ASP.NET programmer, how do
you detect if the visitor is using a mobile browser?
.NET Framework to the rescue:
HttpContext.Current.Request.Browser will give you a HttpBrowserCapabilities object, which has a property IsMobileDevice.
The value of this property will be true if a mobile browser is
detected. This method is looking at the http post headers which
disclose the browser and platform information of the device. You could
check these values yourself, but having access to this property is a
lot easier. Be warned, it doesn't always work because new devices keep
coming out and not every browser brand name is recognized. Here is a
list of officially recognized browsers:
http://www.asp.net/mobile/tested-devices/
For
some additional information on detecting mobile browsers that are not
compatible, and some sample code on how to use both methods, check out
this link:
http://forums.asp.net/p/474014/1162577.aspx