Sniffing Browser Client information

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 />")
%>




OUTPUT is given as:

Name: Dotnetspider
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


Comments

Author: Kapil Dhawan18 Jun 2008 Member Level: Gold   Points : 2

Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code will help lots of guys
Thanks to you
Regards,
Kapil



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: