判断是否是手机浏览的方法
public static bool IsMobile() { string agent = (HttpContext.Current.Request.UserAgent + "").ToLower().Trim(); if (agent == "" || agent.IndexOf("mozilla") != -1 || agent.IndexOf("opera") != -1) return false; return true; }
public bool IsWap() { string agent = (Request.UserAgent + "").ToLower().Trim(); if (agent == "" || agent.IndexOf("mobile") != -1 || agent.IndexOf("mobi") != -1 || agent.IndexOf("nokia") != -1 || agent.IndexOf("samsung") != -1 || agent.IndexOf("sonyericsson") != -1 || agent.IndexOf("mot") != -1 || agent.IndexOf("blackberry") != -1 || agent.IndexOf("lg") != -1 || agent.IndexOf("htc") != -1 || agent.IndexOf("j2me") != -1 || agent.IndexOf("ucweb") != -1 || agent.IndexOf("opera mini") != -1 || agent.IndexOf("mobi") != -1) { //终端可能是手机 return true; } return false ; }