Library code snippets

How to get information about the current browser

This code shows you how ASP.NET simplifies information about the current browser into class properites. There are others but these are the most useful.

<%@ Page Language="c#" %>
<script runat="server">

   public void Page_Load(Object sender, EventArgs e) {
     HttpBrowserCapabilities bc = Request.Browser;
     Response.Write("Name = " + bc.Browser + "<br>");
     Response.Write("Version = " + bc.Version + "<br>");
     Response.Write("Platform = " + bc.Platform + "<br>");
     Response.Write("Is Crawler = " + bc.Crawler + "<br>");
     Response.Write("Is AOL = " + bc.AOL + "<br>");
   }

</script>

Comments

  1. 28 Jul 2007 at 12:04

    WEll its very easy . i was struggling a lot.. thanks pal

  2. 29 Sep 2005 at 20:08
    Aaah! quite easy & useful. Great!
  3. 01 Jan 1999 at 00:00

    This thread is for discussions of How to get information about the current browser.

Leave a comment

Sign in or Join us (it's free).

Edward Tanguay Edward Tanguay updates his personal web site tanguay.info weekly with code, links, quotes and thoughts on web development. Sign up for the free newsletter.

Related podcasts

Events coming up

  • Mar 15

    DevWeek 2010

    London, United Kingdom

    DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.

We'd love to hear what you think! Submit ideas or give us feedback