by Chris
Saturday, July 25 2009
Here is an updated version of the mobile web browser detection and redirection in C-Sharp (#C) for ASP.net. For this to work best, you should add it to the "Application_BeginRequest" event of the global.asax file, located in the root directory.
If you use it, please digg it, tweet it, or link to it. That's all we ask. Thanks!
//mobile device detection and redirection
if (Request.Headers["User-Agent"] != null)
{
if (Request.Browser["IsMobileDevice"] != null && Request.Browser["IsMobileDevice"] == "true")
Response.Redirect("http://mobile.abwebsitedesign.com");
if (Request.Browser["BlackBerry"] != null && Request.Browser["BlackBerry"] == "true")
Response.Redirect("http://mobile.abwebsitedesign.com");
if (Request.UserAgent.ToLower().Contains("iphone"))
Response.Redirect("http://mobile.abwebsitedesign.com");
if (Request.UserAgent.ToUpper().Contains("MIDP") || Request.UserAgent.ToUpper().Contains("CLDC"))
Response.Redirect("http://mobile.abwebsitedesign.com");
}