views:

288

answers:

1

I'm looking at building an exhaustive function that returns a friendly name for the Users Operating System.

I think I have most of the Windows stuff down, but I'm not sure about Linux, OSX, and others.

Does anyone know where I can find an exhaustive list of HTTP_USER_AGENT's

'Gets the users operating system
Public Shared Function GetUserOS() As String

    Dim strAgent As String = HttpContext.Current.Request.ServerVariables("HTTP_USER_AGENT")
    'Windows OS's
    If InStr(strAgent, "Windows NT 6.1") Then : Return "Windows 7"
    ElseIf InStr(strAgent, "Windows NT 6.0") Then : Return "Windows Vista"
    ElseIf InStr(strAgent, "Windows NT 5.2") Then : Return "Windows Server 2003"
    ElseIf InStr(strAgent, "Windows NT 5.1") Then : Return "Windows XP"
    ElseIf InStr(strAgent, "Windows NT 5.0") Then : Return "Windows 2000"
    ElseIf InStr(strAgent, "Windows 98") Then : Return "Windows 98"
    ElseIf InStr(strAgent, "Windows 95") Then : Return "Windows 95"

        'Mac OS's
    ElseIf InStr(strAgent, "Mac OS X") Then : Return "Mac OS X"

        'Linux OS's
    ElseIf InStr(strAgent, "Linux") Then : Return "Linux"

    Else : Return "Unknown"
    End If


End Function 'GetUserOS

I basically want to return better results for Mac OS and Linux OS's. It's better in my opinion to say OSX Snow Leopard or OSX Tiger rather than just Mac OS X

A: 

Here you go.

Oded
Yeah, I found that, but it appears to be for Browsers
rockinthesixstring
Um. And where else would an `HTTP_USER_AGENT` come from? They are there to identify **browsers**.
Oded
I realize it is to identify browsers, but it also contains operating system information. Do you know of a better way (other than HTTP_USER_AGENT) to grab Operating System data from the client? I'm open to suggestions
rockinthesixstring
No, but even then, some browsers lie. There is no fool proof way to get the browser and OS.
Oded
Ok, well I suppose I'll go with what I have currently. Thanks for the direction.
rockinthesixstring