以下代码用来检查,客户端是手机端还是PC端

string strUserAgent =Request.UserAgent.ToString().ToLower();bool isMobile =Request.Browser.IsMobileDevice;if(isMobile || strUserAgent.Contains(“iphone”)|| strUserAgent.Contains(“blackberry”)|| strUserAgent.Contains(“mobile”)|| strUserAgent.Contains(“windows ce”)|| strUserAgent.Contains(“opera mini”)|| strUserAgent.Contains(“palm”)|| strUserAgent.Contains(“samsung”)|| strUserAgent.Contains(“htc”)){//移动端}else{//PC端}

发表回复

您的电子邮箱地址不会被公开。