Display Browser Info in Asp.Net

 

Asp.Net Web Applications will run on IIS Web Server. Whenever IIS receives request for Asp.Net page, it passes the request to Asp.Net engine including Browser Info which sent the request. You can find Browser Info which sent the request at server side in Asp.Net by using Request object.

 

We can get the Browser name, Browser Major Version, Browser Minor Version details by using Request object as shown below.

 

using System;

using System.Text;

 

namespace AspNetWebApp

{

    public partial class _Default : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            StringBuilder sb = new StringBuilder();

            sb.Append("Browser Name: " + Request.Browser.Browser);

            sb.Append("<br/>Browser Major Version: " + Request.Browser.MajorVersion);

            sb.Append("<br/>Browser Minor Version: " + Request.Browser.MinorVersion);

 

            Response.Write(sb.ToString());

        }

    }

}

 

Execute the application and the output is as shown below.

 

Finding Browser Info helps us to track what are the browsers users are using for our application.