标签:string server res long variable regex 电脑 win c#
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("手机访问");
}
标签:string server res long variable regex 电脑 win c#
原文地址:http://www.cnblogs.com/xiaoweigogo/p/7804693.html