Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks

News

Welcome to the Mobile Line Of Business Blog

Tag Cloud


Archives

Post Categories

Image Galleries

About

I've just modified my auto detection web page to work with windows mobile,  iPhone/iPod and now Blackberry

This simple web-page will redirect traffic to different web pages for any of these devices.

Paste this into an asp.net web page (i.e default.aspx)

 

 

<%@ Page Language="C#" Trace="false" %>

<SCRIPT LANGUAGE="C#" RUNAT=SERVER>

    protected void Page_Load(Object sender, EventArgs e)
    {
        System.Web.Mobile.MobileCapabilities cur = (System.Web.Mobile.MobileCapabilities) Request.Browser;

        // this block of code is to detect if users are running Pocket PC 2003
        bool isce=false;
        bool isiphone=false;
            bool isipod=false;
        bool isblackberry=false;

        try    {
               isce = (Request.UserAgent.IndexOf("Windows CE")!=-1);
                   isiphone = (Request.UserAgent.IndexOf("iPhone;")!=-1);
                   isipod = (Request.UserAgent.IndexOf("iPod;")!=-1);
                   isblackberry = (Request.UserAgent.IndexOf("BlackBerry")!=-1);

        }
        catch
        {

        }
        if (isiphone||isipod)
        {
            Response.Redirect("/m");
            return;
        }

        if (isblackberry)
        {
            Response.Redirect("/blackberry");
            return;
        }

        if (cur.IsMobileDevice||isce)
        {               
            Response.Redirect("/mobile");
            return;
        }

        Response.Redirect("/jumpstart");

    }

</SCRIPT>

posted on Monday, October 20, 2008 10:04 PM