I want to get the client's operating system's name (i.e Windows XP, Windows 7, Windows Vista).
Use Request.Browser.Platform
, and the version is in Request.UserAgent
HttpBrowserCapabilities browse = Request.Browser;
string platform = browse.Platform;
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;
}
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