asp.net获取浏览器端操作系统名称
/// <summary>
/// 获取浏览器端操作系统名称
/// </summary>
/// <returns></returns>
public static string GetOSName()
{
string osVersion = System.Web.HttpContext.Current.Request.Browser.Platform;
string userAgent = System.Web.HttpContext.Current.Request.UserAgent;
if (userAgent.Contains("NT 6.2"))
{
osVersion = "Windows8/Server 2012";
}
if (userAgent.Contains("NT 6.1"))
{
osVersion = "Windows7/Server 2008 R2";
}
else 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 = "WindowsXP";
}
else if (userAgent.Contains("NT 5"))
{
osVersion = "Windows2000";
}
else if (userAgent.Contains("NT 4"))
{
osVersion = "WindowsNT4.0";
}
else if (userAgent.Contains("Me"))
{
osVersion = "WindowsMe";
}
else if (userAgent.Contains("98"))
{
osVersion = "Windows98";
}
else if (userAgent.Contains("95"))
{
osVersion = "Windows95";
}
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;
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。