Click here to Skip to main content
Licence 
First Posted 14 Apr 2003
Views 66,119
Bookmarked 33 times

Sniff Web Clients using ASP.NET

By | 14 Apr 2003 | Article
Using .NET Framework web classes one can sniff lots of information from the web clients.

Introduction

This article is about how to sniff web clients using ASP.NET. One can sniff lots of information from the clients using the web classes of the .NET Framework. Well, for those who want to know what is web sniff, it's basically extracting client and browser information. Now the question is why somebody has to sniff the client information? Well, there are two dimensions to this question: one is data capturing for administration, back office and security purposes, which helps us to do some survey like what kind of browsers are connected more, what types of software clients are used more etc.. The second perspective is for developers to know what browser it is and what type of technologies it can support so that the developers can write dynamic web pages depending on the type of the client one connects to. For example, if somebody is connected using Internet Explorer (IE) he can send dynamic HTML pages with VBScript as the client-side script. And if it’s Netscape Navigator he can push dynamic HTML pages with JavaScript as the client-side script. Developers can also check what kind of HTML version the client browser supports etc..

In the .NET Framework, under the System.Web namespace, we have a class HttpBrowserCapabilities. This class helps us to gather information on the capabilities of the browser that is running on the client. Apart from this class, we have a HttpRequest class collection property named ServerVariable. This collection helps to get the complete request header and some client information. In the sample program, I have used both the classes for getting maximum information from the clients. Below is the output of the web sniff ASP.NET program.

I have used C# language for the sample program in ASP.NET. Below is the ASP.NET code Snippet:

<% 
HttpBrowserCapabilities browserObj; 
browserObj = Request.Browser; 
%> 
Client Name:<%=Request.ServerVariables["REMOTE_HOST"]%> 
Client IP Address: <%=Request.ServerVariables["REMOTE_ADDR"]%> 
Platform: <%=browserObj.Platform%> 
Browser String: <%=Request.ServerVariables["http_user_agent"]%> 
Browser Language: <%=Request.ServerVariables["http_accept_language"]%> 
Browser type: <%=browserObj.Type %> 
Browser version: <%=browserObj.Version%> 
Browser Beta: <%=browserObj.Beta%> 
Client CLR Version: <%=browserObj.ClrVersion%> 
Supports ActiveX controls: <%=browserObj.ActiveXControls %> 
Supports Cookies: <%=browserObj.Cookies%> 
Supports Frames: <%=browserObj.Frames%> 
Supports HTML Tables: <%=browserObj.Tables%> 
Supports Java Applets: <%=browserObj.JavaApplets%> 
Supports Java Scripts: <%=browserObj.JavaScript%> 
Supports MS DOM Version: <%=browserObj.MSDomVersion%>

In the class HttpRequest (System.Web namespace), the Browser property returns the HttpBrowserCapabilities class. Using this class, we can get lots of information about the client. The members of the HttpBrowserCapabilties class like Type, Version, Beta, ClrVersion etc.. gives client information. Some of the properties of the HttpBrowserCapabilities class which are used in this sample program are given below:

  • ActiveXControls

    Gets a boolean value indicating whether the client browser supports ActiveX controls.

  • Beta

    Gets a boolean value indicating whether the browser is a beta release.

  • Browser

    Gets the browser string (if any) that was transmitted in the User-Agent header.

  • Clrverson

    Gets the version number of the .NET common language runtime installed on the client.

  • Cookies

    Gets a boolean value indicating whether the client browser supports cookies.

  • Frames

    Gets a boolean value indicating whether the client browser supports HTML frames.

  • JavaApplets

    Gets a boolean value indicating whether the client browser supports Java applets.

  • JavaScript

    Gets a Boolean value indicating whether the client browser supports JavaScript.

  • MSDomVersion

    Gets the version of Microsoft Document Object Model (DOM) that the client browser supports.

  • Platform

    Gets the name of the platform that the client uses.

  • Tables

    Gets a boolean value indicating whether the client browser supports HTML tables.

  • Type

    Gets name and major version number of the client browser.

  • VBScript

    Gets a boolean value indicating whether the client browser supports VBScript.

  • Version

    Gets the full (integer and decimal) version number of the client browser.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Chandra Hundigam

Architect

United States United States

Member

Chandra Hundigam has Master degree in Computer Application, Microsoft Certified Professional and Software Architect. He's significantly involved in enterprise application development and distributed object oriented system development using Microsoft .Net, Sun Java/J2EE technology to serve global giants in the Media, Finance, Mortgage and Software Industries.Presently working as Independent Software Consultant for a US-based company.His areas of interests are in emerging Technologies.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralClient Name PinsussAnonymous11:43 24 Mar '04  
GeneralSniffing PinmemberSharry0012319:22 14 Mar '04  
GeneralKnow that explorer is closed PinmemberM Saad++9:02 6 Feb '04  
GeneralRe: Know that explorer is closed PinmemberSharry0012319:23 14 Mar '04  
GeneralRe: Know that explorer is closed PinsussAnonymous5:06 15 Mar '04  
GeneralCountry data Pinmembersalema2:35 18 Nov '03  
GeneralSniffing PinsussAnonymous21:53 10 Sep '03  
GeneralSniffing PinsussCurious Person - Repeat22:03 18 Aug '03  
GeneralRe: Sniffing PinmemberStephane Rodriguez.22:15 18 Aug '03  
GeneralSniffing HTML or Text Emails PinsussCurious Person22:00 18 Aug '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 15 Apr 2003
Article Copyright 2003 by Chandra Hundigam
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid