How to detect browser Operating System (OS) with ASP.NET
14-04-2008 15:10:30
Last week, I did solve another operating system different
problem.
The problem started when I should post a specific operating system program from a link, My first
opinion was to try the embedded ASP.NET request
"Request.Browser.Platform", I works quite well on MAC, XP
and so on, but when i did try Vista, It just returns
"WinNT", which also is used for naming Windows
2000.
So I couldn't use this "smart" function anyway. So I
did take a look on the User Agent from the browser
instead, which is more informative than the embedded platform
function.
You can use "Request.UserAgent" if you're
programming ASP.NET, otherwise it quite simple to
get through other programming languages or the client script by
Javascript.
Back to the returns of "Request.UserAgent"
which is for an example
"Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.8.1.13)
Gecko/20080311 Firefox/2.0.0.13"..
Some of these information's returns which browser system,
browser version, operating system and version you
are using, which is very usefully, when you're trying to determine
the user operating system. If you knows the user operating system
(You can request it in ASP.NET by
"Request.Browser.Platform", and wants to know know the
specific version like 2000, XP and Vista.
You can check if the OS version number is in the User
agent. If you're looking in the example I did post above
this text, you can see a Windows NT number, that's the number who
indicate the specific Windows version. "Windows NT
5.1" means that this user is using Windows
XP.
You can find the specific version number on this page http://en.wikipedia.org/wiki/Comparison_of_Windows_versions.
And after this research I could delivery the correct file for the
specific operating system (OS). Hope
some of you, could use this information, please make a comment if
you're having some questions, other ways to get this information,
feel free to contact me.
Kommentarer
Tilføj en kommentar