欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-04-12 16:57:48
bool flag = false; string agent = System.Web.HttpContext.Current.Request.UserAgent.ToLower(); string[] keywords = { "iphone", "ipod", "ipad", "itouch"... ......
     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")
{
微信浏览器
}