Click here to Skip to main content
Licence CPOL
First Posted 29 Jan 2003
Views 51,972
Bookmarked 30 times

Retrieving UserAgent Details in .NET

By | 29 Jan 2003 | Article
In this small article, we would see in brief about retrieving details about the useragent that is visiting our page. This information would be vital in analyzing the patterns of user's visits to portals and similar websites.

Introduction

It has been indeed a long story of browser wars and browser compatibility and Webmasters have always been constantly having their fingers crossed to keep their websites/web applications as compatible as far as possible amongst the major browsers. With the advent of ASP.NET, making the web pages compatible with at least the major browsers has been made a bit easier and a pleasant thing to work with.

Server-Centric Model

With all validator controls and other major parts of a webpage are now made as Server Controls, the Web Server now takes the responsibility of rendering the pages that is optimal to the client browser. While Validator controls deliver rich client side validations for an up level browser like MSIE 5.5 or higher, with older browsers, the page automatically posts back to the Server but of course, Server Side Processing Scripts are deferred from executing till the Page.IsValid is true. This greatly eliminates the need of redundant client side validation for each browser.

Enriching Page Content

However, with high traffic portal applications, the Webmaster might be concerned with delivering the best browsing experience and a page that best renders on each type of browsers, rather than depending upon the automatic down leveling strategy adopted by ASP.NET with its Server-Centric trick. ASP.NET Comes to our rescue in detecting the browser and its abilities with is Request.Browser property

Detecting Browsers With Request Object

Request.Browser depends on System.Web.HttpBrowserCapabilities class and this property exposes a host of information regarding the browser/user agent that is visiting our page. Included typically are whether the browser supports the latest W3C DOM and whether it is a simple web browser and a Crawler that is crawling the webpage.

The sample example that is available along with this article gives an example of detecting the browser whether it is a Crawler, queries its DOM support and some brief information about whether Microsoft .NET is installed and the CLR version.

Conclusion

I hope the above article would be greatly useful to developers involved in delivering ASP.NET Web Portal applications and to webmasters in making their web portals/applications best render with different types of web browsers, making the best use of the support that ASP.NET offers towards browser compatibility.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Vasudevan Deepak Kumar

Web Developer

India India

Member

Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College (now VIT University). He also has a MBA in Systems from Alagappa University, Karaikudi, India.


He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000. For sometime, he has also been with PHP and MySQL based development in one of his previous organizations. Now currently his focus is on Microsoft .NET World (ASP.NET, C# and Whidbey)


In his past-time, he listens to polite Carnatic Music.

Web Presence


Homepage

http://www.lavanyadeepak.tk/

Blogs



Technical




Gossips



Spiritual







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
GeneralMy vote of 1 PinmemberHenry Minute7:00 28 Sep '09  
Questionlavanyadeepak.browserpeek ? PinmemberKastellanos Nikos21:26 3 Feb '03  
AnswerRe: lavanyadeepak.browserpeek ? PinmemberDeepak Kumar Vasudevan21:38 3 Feb '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
Web01 | 2.5.120517.1 | Last Updated 30 Jan 2003
Article Copyright 2003 by Vasudevan Deepak Kumar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid