判断客户端是iOS还是Android,判断是不是在微信浏

作者: 编程  发布:2019-11-21
     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")
{
微信浏览器
}

9159.com, 

本文由9159.com发布于编程,转载请注明出处:判断客户端是iOS还是Android,判断是不是在微信浏

关键词: