1个回答
展开全部
您好,
// 获取当前URL地址
Request.Url.ToString();
// 浏览器
Request.Browser.Type.ToString();
Request.UserAgent.ToString()
//操作系统
cp=GetOSNameByUserAgent(Request.UserAgent.ToString());
/ /浏览器版本号
Request.Browser.ClrVersion.ToString();
// 来源网址
Request.ServerVariables["http_referer"];
/// <summary>
/// 根据 User Agent 获取操作系统名称
/// </summary>
private string GetOSNameByUserAgent(string userAgent)
{
string osVersion = "未知";
if (userAgent.Contains("NT 6.0"))
{
osVersion = "Windows Vista/Server 2008";
}
else if (userAgent.Contains("NT 5.2"))
{
osVersion = "Windows Server 2003";
}
else if (userAgent.Contains("NT 5.1"))
{
osVersion = "Windows XP";
}
else if (userAgent.Contains("NT 5"))
{
osVersion = "Windows 2000";
}
else if (userAgent.Contains("NT 4"))
{
osVersion = "Windows NT4";
}
else if (userAgent.Contains("Me"))
{
osVersion = "Windows Me";
}
else if (userAgent.Contains("98"))
{
osVersion = "Windows 98";
}
else if (userAgent.Contains("95"))
{
osVersion = "Windows 95";
}
else if (userAgent.Contains("Mac"))
{
osVersion = "Mac";
}
else if (userAgent.Contains("Unix"))
{
osVersion = "UNIX";
}
else if (userAgent.Contains("Linux"))
{
osVersion = "Linux";
}
else if (userAgent.Contains("SunOS"))
{
osVersion = "SunOS";
}
return osVersion;
}
// 获取当前URL地址
Request.Url.ToString();
// 浏览器
Request.Browser.Type.ToString();
Request.UserAgent.ToString()
//操作系统
cp=GetOSNameByUserAgent(Request.UserAgent.ToString());
/ /浏览器版本号
Request.Browser.ClrVersion.ToString();
// 来源网址
Request.ServerVariables["http_referer"];
/// <summary>
/// 根据 User Agent 获取操作系统名称
/// </summary>
private string GetOSNameByUserAgent(string userAgent)
{
string osVersion = "未知";
if (userAgent.Contains("NT 6.0"))
{
osVersion = "Windows Vista/Server 2008";
}
else if (userAgent.Contains("NT 5.2"))
{
osVersion = "Windows Server 2003";
}
else if (userAgent.Contains("NT 5.1"))
{
osVersion = "Windows XP";
}
else if (userAgent.Contains("NT 5"))
{
osVersion = "Windows 2000";
}
else if (userAgent.Contains("NT 4"))
{
osVersion = "Windows NT4";
}
else if (userAgent.Contains("Me"))
{
osVersion = "Windows Me";
}
else if (userAgent.Contains("98"))
{
osVersion = "Windows 98";
}
else if (userAgent.Contains("95"))
{
osVersion = "Windows 95";
}
else if (userAgent.Contains("Mac"))
{
osVersion = "Mac";
}
else if (userAgent.Contains("Unix"))
{
osVersion = "UNIX";
}
else if (userAgent.Contains("Linux"))
{
osVersion = "Linux";
}
else if (userAgent.Contains("SunOS"))
{
osVersion = "SunOS";
}
return osVersion;
}
追问
没有WIN8,WIN7什么的?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询