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.