Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get operating system version asp.net

I want to get the os version that the browser opens, actually my project is an asp.net project and i want to know which operating system runs on the client but there is a question about it. Because the client will use xp but at the same time will use Windows CE 5.0, so the internet explorer in Windows CE is not as good as the one in xp, because of it i'll redirect the user to the page that i designed for Windows CE. So is there any solution to do it?

Thank you..

like image 384
mehmetserif Avatar asked Feb 18 '09 15:02

mehmetserif


People also ask

What version is asp net?

The 4.8 version of the ASP.NET is the latest version of the framework released in 2019.

What OS version do I have?

To find out which Android OS is on your device: Open your device's Settings. Tap About Phone or About Device. Tap Android Version to display your version information.


3 Answers

Use Request.UserAgent - that will probably give all the information you need.

There's a "List of User-Agents" web site which gives lots of sample strings, but if your client has a limited range of setups, it would be worth just trying each of them and logging the user agent as a preliminary step.

Be aware that many browsers will allow you to "spoof" the user agent string, so you mustn't use this for security purposes - but it sounds as if your use case is pretty reasonable.

like image 183
Jon Skeet Avatar answered Oct 20 '22 16:10

Jon Skeet


The gist of it is use Request.Browser.Platform, and the version is in Request.UserAgent.

like image 45
Tim Sullivan Avatar answered Oct 20 '22 15:10

Tim Sullivan


Since the selected answer is not up to date and supplied a broken link I have decided to publish the way I accomplished it:

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 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;
        }
like image 27
Offir Avatar answered Oct 20 '22 15:10

Offir