判断客户端是iOS还是Android,判断是不是在微信浏览器打开

     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")
{
微信浏览器
}

 

posted @ 2018-06-26 13:49  过一天日子修一天缘  阅读(438)  评论(1编辑  收藏  举报