判斷客戶端是iOS還是Android,判斷是不是在微信瀏覽器開啟

小倔驢發表於2018-06-26
     bool flag = false;
            string agent = System.Web.HttpContext.Current.Request.UserAgent.ToLower();
            string[] keywords = { "iphone", "ipod", "ipad", "itouch" };

            foreach (string item in keywords)
            {
                if (agent.Contains(item))
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                ViewBag.Phone = "iOS";
            }
            else {
                ViewBag.Phone = "Android";
            }
 if (agent.ToLower().Contains("micromessenger")
{
微信瀏覽器
}

 

相關文章