Click here to Skip to main content
Click here to Skip to main content

Sniff Web Clients using ASP.NET

, 14 Apr 2003
Rate this:
Please Sign up or sign in to vote.
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
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.

Comments and Discussions

 
GeneralClient Name PinsussAnonymous24-Mar-04 11:43 
GeneralSniffing PinmemberSharry0012314-Mar-04 19:22 
GeneralKnow that explorer is closed PinmemberM Saad++6-Feb-04 9:02 
GeneralRe: Know that explorer is closed PinmemberSharry0012314-Mar-04 19:23 
GeneralRe: Know that explorer is closed PinsussAnonymous15-Mar-04 5:06 
GeneralCountry data Pinmembersalema18-Nov-03 2:35 
GeneralSniffing PinsussAnonymous10-Sep-03 21:53 
GeneralSniffing PinsussCurious Person - Repeat18-Aug-03 22:03 
GeneralRe: Sniffing PinmemberStephane Rodriguez.18-Aug-03 22:15 
GeneralSniffing HTML or Text Emails PinsussCurious Person18-Aug-03 22:00 

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.

| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 15 Apr 2003
Article Copyright 2003 by Chandra Hundigam
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid