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:
browserObj = Request.Browser;
Client IP Address: <%=Request.ServerVariables["REMOTE_ADDR"]%>
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 MS DOM Version: <%=browserObj.MSDomVersion%>
In the class
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
ClrVersion etc.. gives client information. Some of the properties of the
HttpBrowserCapabilities class which are used in this sample program are given below:
Gets a boolean value indicating whether the client browser supports ActiveX controls.
Gets a boolean value indicating whether the browser is a beta release.
Gets the browser string (if any) that was transmitted in the User-Agent header.
Gets the version number of the .NET common language runtime installed on the client.
Gets a boolean value indicating whether the client browser supports cookies.
Gets a boolean value indicating whether the client browser supports HTML frames.
Gets a boolean value indicating whether the client browser supports Java applets.
Gets the version of Microsoft Document Object Model (DOM) that the client browser supports.
Gets the name of the platform that the client uses.
Gets a boolean value indicating whether the client browser supports HTML tables.
Gets name and major version number of the client browser.
Gets a boolean value indicating whether the client browser supports VBScript.
Gets the full (integer and decimal) version number of the client browser.