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..
The 4.8 version of the ASP.NET is the latest version of the framework released in 2019.
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.
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.
The gist of it is use Request.Browser.Platform
, and the version is in Request.UserAgent
.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With