简体   繁体   中英

How to detect the client OS from ASP.NET

I would like to detect the client operating system using ASP.NET and C#. The HttpBrowserCapabilities class lets me determine the browser information very well, like "Chrome" and version "29.0". BUT, it does not help me adequately with the operating system. The "platform" property only returns "WinNT". Well, I am using Windows 7 and obviously not the older "WinNT" so on a practical level, this does not help me.

Now, I do know that I could parse out bits of the UserAgent string manually and look for things like "Windows NT 6.1" and manually convert that to "Windows 7". I have no problem doing that for 5 or even 10 versions of Windows. BUT, I definitely do not want to write manual code for all of these conversions for EVERY operating system on the planet.

Does anyone know how I can detect the client OS from my web code without hand-writing hundreds or thousands of lines of useragent parsing? I have seen other websites show "You are using Windows 7" on their web pages. I would prefer not to buy a 3rd party object for this.

You can use API from UserAgentString.com

http://www.useragentstring.com/pages/api.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM