The User-agent passed by the client is used to determine whether the client accessing the website is a PC or a mobile phone. In. NET, Request. ServerVariables ["HTTP_USER_AGENT"].
For example, the normal pc is Mozilla/5.0 (Windows NT 6.1; rv: 27.0) Gecko/20100101 Firefox/27.0
Commonly used mobile phones are:
Nokia5320: Nokia 5320/UCWEB7.0.1.34/28/999
HTC Android phone: Mozilla/5.0 (Linux; U; Android 2.2; zh-cn; HTC Desire Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) version/4.0 Mobile Safari/533.1;
IPhone: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; zh-cn) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7D11
Method: Use a regular expression to match and judge. The Code is as follows:
Str_u = Request. ServerVariables [= Regex (, RegexOptions. IgnoreCase | = Regex (, RegexOptions. IgnoreCase | (! (B. IsMatch (str_u) | v. IsMatch (str_u.Substring (, Response. Redirect (, Response. Redirect (,
PS: No problem found.