Collecting lots of browser information from the visitor with VB .NET in ASP .NET.
Any website that generates a decent traffic needs a statistic page. So how do you collect statistics?
ASP .NET knows how to sniff some information from the visitor, from basic information like the browser version to information about the support of Java Applets and ActiveX Controls.
The following is VB .NET code for displaying client information with ASP .NET:
<%
response.write("<b>Name:</b> " & Request.ServerVariables("REMOTE_HOST") & "<br />")
response.write("<b>IP:</b> " & Request.ServerVariables("REMOTE_ADDR") & "<br />")
response.write("<b>User agent:</b> " & Request.ServerVariables("HTTP_USER_AGENT") & "<br />")
response.write("<b>Language:</b> " & Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") & "<br />")
response.write("<b>Browser:</b> " & Request.Browser.Browser & "<br />")
response.write("<b>Type:</b> " & Request.Browser.Type & "<br />")
response.write("<b>Version:</b> " & Request.Browser.Version & "<br />")
response.write("<b>Major version:</b> " & Request.Browser.MajorVersion & "<br />")
response.write("<b>Minor version:</b> " & Request.Browser.MinorVersion & "<br />")
response.write("<b>Beta:</b> " & Request.Browser.Beta & "<br />")
response.write("<b>Cookies:</b> " & Request.Browser.Cookies & "<br />")
response.write("<b>Frames:</b> " & Request.Browser.Frames & "<br />")
response.write("<b>Tables:</b> " & Request.Browser.Tables & "<br />")
response.write("<b>ActiveX:</b> " & Request.Browser.ActiveXControls & "<br />")
response.write("<b>Java Applets:</b> " & Request.Browser.JavaApplets & "<br />")
response.write("<b>JavaScript:</b> " & Request.Browser.JavaScript & "<br />")
response.write("<b>VBScript:</b> " & Request.Browser.VBScript & "<br />")
response.write("<b>Platform:</b> " & Request.Browser.Platform & "<br />")
response.write("<b>Crawler:</b> " & Request.Browser.Crawler & "<br />")
%>
Here is a sample result:
Name: geekpedia
IP: 127.0.0.1
User agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)
Language: en-us
Browser: IE
Type: IE6
Version: 6.0
Major version: 6
Minor version: 0
Beta: False
Cookies: True
Frames: True
Tables: True
ActiveX: True
Java Applets: True
JavaScript: True
VBScript: True
Platform: WinXP
Crawler: False