Visitors' Browser Information

The information that is available to client-side scripts (ie JavaScript) regarding browser version, operating system etc. is also made available to ASP scripts. For example, to get the visitor's browser, you can use

Response.Write Request.ServerVariables("HTTP_USER_AGENT")

Below are some examples of the values that can be returned:

'Windows NT 4, IE 6
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)

'Windows 2000, IE 5.01
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

'Netscape 6.1, Windows 98
Mozilla/5.0 (windows; u; windows 98; en-us; rv:0.9.2) gecko/20010726 netscape6/6.1

'Opera, Windows 95
Mozilla/5.0 (windows 95; u) opera 5.01 [en]

Obviously, to determine the user's browser using code is not particularly straight forward. Obviously, you can check if it is IE by using

If InStr(1, Request.ServerVariables("HTTP_USER_AGENT"),"MSIE") Then
    'is Microsoft Internet Explorer
End If

However, retrieving any more detailed information is very difficult. Fortunately, Microsoft have the answer (!), with their Browser Capabilities component. This component reveals not only what make of browser it is, but whether it supports frames, vb script etc. Below is a simple example

'Create an instance of the Browser Capabilities Component
Dim objBC
Set objBC = Server.CreateObject("MSWC.BrowserType")
<b>Your browser:</b> <%=objBC.Browser%><br>
<b>Browser version:</b> <%=objBC.Version%><br>
<b>Support Frames?</B> <%=objBC.Frames%><br>

Having said that, it can't be entirely relied upon; it identifies my copy of IE 6 as Netscape 4.0! (The Browser Capabilities component gets its information from c:\winnt\system32\inetsrv\browscap.ini)

You might also like...


James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer Science is no more about computers than astronomy is about telescopes.” - E. W. Dijkstra