C# 判断用户用手机访问还是用电脑访问网页
string osPat = "mozilla|m3gate|winwap|openwave|Windows NT|Windows 3.1|95|Blackcomb|98|ME|X Window|Longhorn|ubuntu|AIX|Linux|AmigaOS|BEOS|HP-UX|OpenBSD|FreeBSD|NetBSD|OS/2|OSF1|SUN";
string uAgent = Request.ServerVariables["HTTP_USER_AGENT"];
Regex reg = new Regex(osPat);
if (reg.IsMatch(uAgent))
{
Response.Write("电脑访问");
}
else
{
Response.Write("手机访问");
}
时间: 2024-10-12 16:17:10