Browser detection

cnd picture cnd · Feb 8, 2010 · Viewed 116.8k times · Source

I need to separate IE and FF browsers from others

it's a pseudo-code :

If (CurrentBrowser == IE(6+) or FF(2+) )
{
...
}
else 
{
...
}

in protected void Page_Load() event (think so)

if ((Request.Browser.Type == "IE") || (Request.Browser.Type == "FF"))
{
    WebMsgBox.Show("1111");
}

no effects :-/ what is IE and FF types?

Answer

Asad picture Asad · Feb 8, 2010
if (Request.Browser.Type.Contains("Firefox")) // replace with your check
{
    ...
} 
else if (Request.Browser.Type.ToUpper().Contains("IE")) // replace with your check
{
    if (Request.Browser.MajorVersion  < 7)
    { 
        DoSomething(); 
    }
    ...
}
else { }