in

DavidJBerman.com

An online community of advocacy and support of entrepreneurial ventures

C sharp (C#)

April 2008 - Posts

  • How to detect a mobile web browser using ASP.NET 2.0

     

    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
     

  • Optimizing your ASP.NET 2.0 website performance

    I just discovered this great article on codeproject.com for optimizing ASP.NET 2.0 website performance:

    http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx by Omar Al Zabir titled 10 ASP.NET Performance and Scalability Secrets.

    I wanted to pin it on my blog so this article doesn't get missed.  There is some good practical information here on how to tweak your ASP.NET configuration for improved performance.



     
     

    Posted Apr 10 2008, 11:05 AM by Dave with no comments
    Filed under:
More Posts
Copyright 2006 David J. Berman, all rights reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems