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).

AddThis

Related podcasts

  • CodeCast Episode 4: State of .NET, IE8, ASP.NET MVC, and O'Reilly Media

    CodeCast Episode 4: State of .NET, IE8, ASP.NET MVC, and O'Reilly MediaHosts Ken Levy and Markus Egger discuss the new State of .NET events, IE8, ASP.NET MVC, followed by an interview from PDC with two editors from O'Reilly Media. More on ASP.NET MVC can be found at http://asp.net/mvc. Interview...

Related jobs

Events coming up