...
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; }