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>

You might also like...

Comments

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.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne