Click here to Skip to main content
15,910,603 members
Articles / Web Development / ASP.NET
Article

Sniff Web Clients using ASP.NET

Rate me:
Please Sign up or sign in to vote.
1.73/5 (9 votes)
14 Apr 20033 min read 84.1K   449   34   10
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.

Image 1

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

ASP.NET
<% 
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


Written By
Architect
United States United States
Chandra Hundigam-Venkat has Master degree in Computer Application, Microsoft Certified Professional and Cloud & Software Architect. Significantly involved in Cloud solutions, Cloud native application, Cloud migration, Enterprise application development distributed object oriented system development. Started computer career at the early age of eighteen as an intern in computer labs and had the opportunity to work with various USA fortune 500 companies in various technology and leadership roles.


Comments and Discussions

 
GeneralClient Name Pin
Anonymous24-Mar-04 11:43
Anonymous24-Mar-04 11:43 
GeneralSniffing Pin
Sharry0012314-Mar-04 19:22
Sharry0012314-Mar-04 19:22 
GeneralKnow that explorer is closed Pin
M Saad++6-Feb-04 9:02
M Saad++6-Feb-04 9:02 
Can you find out that an ASP web form is closed, i.e. recieve an event when the browser is closed?
GeneralRe: Know that explorer is closed Pin
Sharry0012314-Mar-04 19:23
Sharry0012314-Mar-04 19:23 
GeneralRe: Know that explorer is closed Pin
Anonymous15-Mar-04 5:06
Anonymous15-Mar-04 5:06 
GeneralCountry data Pin
salema18-Nov-03 2:35
salema18-Nov-03 2:35 
GeneralSniffing Pin
Member 59282810-Sep-03 21:53
Member 59282810-Sep-03 21:53 
GeneralSniffing Pin
Member 59282818-Aug-03 22:03
Member 59282818-Aug-03 22:03 
GeneralRe: Sniffing Pin
Stephane Rodriguez.18-Aug-03 22:15
Stephane Rodriguez.18-Aug-03 22:15 
GeneralSniffing HTML or Text Emails Pin
Member 59282818-Aug-03 22:00
Member 59282818-Aug-03 22:00 

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

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