public static bool CheckAgent() { bool flag = false; string agent = HttpContext.Current.Request.UserAgent; string[] keywords = { "Android", "iPhone", "Windows Phone", "MQQBrowser" }; //排除 Windows 桌面系统 苹果桌面系统 if (!agent.Contains("Windows NT") && !agent.Contains("Macintosh")) { foreach (string item in keywords) { if (agent.Contains(item)) { flag = true; break; } } } return flag; }