Apr 7 2008
Mobile Browser User-Agent Detector
While working on a project recently I needed to be able to determine if the user was coming to the ASP.Net site was using a mobile browser. In my particular case, the IsMobileBrowser property didn't work so I created this code to do it for me, based on the information i gleamed from http://www.zytrax.com/tech/web/mobile_ids.html. Enjoy.
string[] arr = new string[] { "Windows CE", "PlayStation Portable", "PLAYSTATION 3", "Symbian OS", "SonyEricsson", "Opera Mini", "SIE", "Vodafone", "SEC", "SAMSUNG", "SCH", "240x320", "MobileExplorer", "PalmSource", "PalmOS", "Smartphone", "BlackBerry", "iPhone" }; foreach (string s in arr) { if (Context.Request.UserAgent.ToLower().Contains(s.ToLower())) Response.Redirect("/mobile.aspx"); }