c# 判断是否是手机访问
public static bool CheckAgent() { bool flag = false; string agent = HttpContext.Current.Request.UserAgent; string[] keywords = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" }; //排除 Windows 桌面系统 if (!agent.Contains("Windows NT") || (agent.Contains("Windows NT") && agent.Contains("compatible; MSIE 9.0;"))) { //排除 苹果桌面系统 if (!agent.Contains("Windows NT") && !agent.Contains("Macintosh")) { foreach (string item in keywords) { if (agent.Contains(item)) { flag = true; break; } } } } return flag; }
从此山高路远,纵马扬鞭。愿往后旅途,三冬暖,春不寒,天黑有灯,下雨有伞。此生尽兴,不负勇往。