Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the client's operating system's name

Tags:

c#

.net

asp.net

I want to get the client's operating system's name (i.e Windows XP, Windows 7, Windows Vista).

like image 738
masif Avatar asked Aug 19 '11 06:08

masif


3 Answers

Use Request.Browser.Platform, and the version is in Request.UserAgent

like image 162
Tejo Avatar answered Oct 28 '22 15:10

Tejo


HttpBrowserCapabilities browse = Request.Browser;
string platform = browse.Platform;
like image 35
Waqas Avatar answered Oct 28 '22 15:10

Waqas


I installed a cool tool named: https://github.com/ua-parser/uap-csharp
that parse the user agent to OS,Browser,Browser version etc...
Link to Nuget.

And this is how used it:

 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;
        }
like image 21
Offir Avatar answered Oct 28 '22 13:10

Offir