How to get asp.net operating system version

I want to get the version of os that the browser opens, in fact my project is an asp.net project, and I want to know which operating system is running on the client, but there is a question about this. Since the client will use xp, but at the same time it will use Windows CE 5.0, so the Internet Explorer in Windows CE is not as good as the one in xp, because of this I redirect the user to the page that I developed for Windows CE So is there any solution for this?

Thanks..

+5
source share
6 answers

Its essence is to use Request.Browser.Platform, and the version is in Request.UserAgent.

+4

Request.UserAgent - , , .

" " , , , .

, "" , , , .

+9

, , :

: https://github.com/ua-parser/uap-csharp, , , ...

Nuget.

:

public static string GetUserBrowser(string userAgent)
        {
            // get a parser with the embedded regex patterns
            var uaParser = Parser.GetDefault();
            ClientInfo c = uaParser.Parse(userAgent);
            return c.UserAgent.Family;
        }


 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

USER_AGENT ( ) .

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

All Articles