我想獲取客戶端的操作系統名稱(即Windows XP,Windows 7,Windows Vista)。獲取客戶端的操作系統名稱
回答
HttpBrowserCapabilities browse = Request.Browser;
string platform = browse.Platform;
我相信這個結果'WinNT'在XP,Vista和7上不是很有用。 – Bazzz
最好使用下面提到的nuget UAParser。 –
使用Request.Browser.Platform
,並且版本是Request.UserAgent
@abatishchev Request.UserAgent給了我'Mozilla/5.0(compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)' – masif
@aaa:其實這就是Tejo的答案。 Windows 6.1意味着Windows 7或Windows Server 2008 R2 – abatishchev
感謝您的info..Windows 6.1意味着Windows 7或Windows Server 2008 R2。由@Waqas提供的鏈接幫助我解決了我的問題。 – masif
OperatingSystem os = Environment.OSVersion;
var platform = os.Platform.ToString();
var version = os.Version.ToString();
var servicePack = os.ServicePack.ToString();
您還可以找到與用戶代理的幫助。
String userAgent = Request.UserAgent;
if (userAgent.IndexOf("Windows NT 6.3") > 0)
{
//Windows 8.1
}
else if (userAgent.IndexOf("Windows NT 6.2") > 0)
{
//Windows 8
}
else if (userAgent.IndexOf("Windows NT 6.1") > 0)
{
//Windows 7
}
else if (userAgent.IndexOf("Windows NT 6.0") > 0)
{
//Windows Vista
}
else if (userAgent.IndexOf("Windows NT 5.2") > 0)
{
//Windows Server 2003; Windows XP x64 Edition
}
else if (userAgent.IndexOf("Windows NT 5.1") > 0)
{
//Windows XP
}
else if (userAgent.IndexOf("Windows NT 5.01") > 0)
{
//Windows 2000, Service Pack 1 (SP1)
}
else if (userAgent.IndexOf("Windows NT 5.0") > 0)
{
//Windows 2000
}
else if (userAgent.IndexOf("Windows NT 4.0") > 0)
{
//Microsoft Windows NT 4.0
}
else if (userAgent.IndexOf("Win 9x 4.90") > 0)
{
//Windows Millennium Edition (Windows Me)
}
else if (userAgent.IndexOf("Windows 98") > 0)
{
//Windows 98
}
else if (userAgent.IndexOf("Windows 95") > 0)
{
//Windows 95
}
else if (userAgent.IndexOf("Windows CE") > 0)
{
//Windows CE
}
else
{
//Others
}
我安裝了一個名爲一個很酷的工具:https://github.com/ua-parser/uap-csharp
用來解析用戶代理的操作系統,瀏覽器,瀏覽器版本等...
Link to Nuget。
這是如何使用它:
public static string GetUserOS(string userAgent)
{
// get a parser with the embedded regex patterns
var uaParser = Parser.GetDefault();
ClientInfo c = uaParser.Parse(userAgent);
return c.OS.Family;
}
- 1. PHP獲取當前客戶端操作系統語言
- 2. 如何獲得操作系統名稱
- 3. 獲取客戶端計算機名稱
- 4. 獲取客戶操作系統/瀏覽器的詳細信息
- 5. WMI - 獲取未本地化的操作系統名稱
- 6. 在WIX中獲取完整的操作系統名稱
- 7. 獲取Linux的通用操作系統名稱Python
- 8. 獲取操作系統Win 7用戶名Javascript
- 9. 確定客戶端操作系統在PHP
- 10. 如何通過PHP和Javascript知道客戶端操作系統?
- 11. 系統ID和客戶端更改管理系統別名
- 12. 如何獲得操作系統的語言名稱
- 13. 獲取客戶端系統的硬盤序列號
- 14. 獲取Nancy的操作系統/平臺
- 15. c#獲取客戶端用戶名
- 16. 如何獲取使用C#運行代碼的操作系統的名稱?
- 17. 客戶端操作系統上的DNS查詢是否已係列化?
- 18. 如何獲得「友好」操作系統版本名稱?
- 19. 如何動態獲取系統名稱?
- 20. 獲取網絡終端的操作系統版本(JAVA)
- 21. 如何從客戶操作系統獲取Citrix XenServer VM的唯一ID?
- 22. 獲取客戶瀏覽器和操作系統信息所需的服務
- 23. 如何獲取vb.net中選定計算機的操作系統名稱?
- 24. WCF客戶端類名稱
- 25. 獲取本地系統的用戶名
- 26. 在UNIX類型的操作系統中獲取當前用戶帳戶的顯示名稱
- 27. 獲取客戶端的IP地址和計算機名稱?
- 28. 獲取操作系統版本
- 29. 從操作系統獲取事件
- 30. 不使用WMI獲取操作系統
閱讀下面的最新解決方案我的答案。 –