Home Calendar Observing Glossary About Course Notes Celestia CranNet Conceptual Physics F. R. Higgins Everything Else
string nmpar = "nomobile"; string nmpart = "true"; var res = HttpContext.Current.Request.Params[nmpar]; if (res != null && res.ToLower().IndexOf(nmpart) > -1) { Response.Cookies[nmpar].Value = nmpart; } else if (Request.Cookies[nmpar] == null || Request.Cookies[nmpar].Value != nmpart) { string mobile_site_url = "http://m.carpecaelum.com/"; bool is_mobile = false; string accept = HttpContext.Current.Request.Headers["HTTP_ACCEPT"]; if (accept == null) accept = ""; if (HttpContext.Current.Request.Headers["HTTP_X_WAP_PROFILE"] != null || HttpContext.Current.Request.Headers["HTTP_PROFILE"] != null) { is_mobile = true; } else if (accept.Contains("text/vnd.wap.wml") || accept.Contains("application/vnd.wap.xhtml+xml")) { is_mobile = true; } else { string[] mobiles = {"Android", "BlackBerry", "iPAQ", "iPhone", "iPod", "Windows CE", "Windows Phone", "Palm", "Symbian", "Alcatel", "Asus", "Ericsson", "Fly", "Huawei", "i-mate", "LG-", "LGE-", "MDS_", "MOT-", "Nokia", "Opera Mini", "Opera Mobi", "Panasonic", "Pantech", "Philips", "Sagem", "Samsung", "Sharp", "SIE-", "Vodafone", "Voxtel", "WebOS", "ZTE-"}; foreach (string m in mobiles) { if (Request.UserAgent.Contains(m)) { is_mobile = true; break; } } } if(is_mobile) Response.Redirect(mobile_site_url);