2011-08-19 10 views

答えて

3
HttpBrowserCapabilities browse = Request.Browser; 
string platform = browse.Platform; 
+3

XP、Vista、および7でこの結果が「WinNT」と思われます。 – Bazzz

+1

下記のナゲットUAParserを使用する方が良いです。 –

5

使用Request.Browser.Platform、およびバージョンがあなたはまた、ユーザエージェントの助けを借りて見つけることができますRequest.UserAgent

+0

Request.UserAgentが「Mozilla/5.0(MSIE 9.0、Windows NT 6.1、WOW64、Trident/5.0)」 – masif

+1

@aaa:Tejoの答えです。 Windows 6.1は、Windows 7またはWindows Server 2008 R2を意味します。 – abatishchev

+0

info ... Windows 6.1は、Windows 7またはWindows Server 2008 R2を意味します。 @Waqasが提供するリンクは、私の問題解決に役立ちました.. – masif

0
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 
     } 
2

私は名前のクールなツールがインストール:https://github.com/ua-parser/uap-csharp

Link to Nuget ... OS、ブラウザ、ブラウザのバージョンなどにユーザーエージェントを解析します。

そして、これはそれを使用する方法である:

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; 
     } 
関連する問題