Use code to determine the browser version used by the client
Response. Write (Request. ServerVariables ["HTTP_USER_AGENT"]); (it seems that this is also available on ASP)
Or
Response. Write (Request. UserAgent );
I have IE7 output:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SE 1.X;. net clr 2.0.50727;. net clr 3.0.04506.648;. net clr 3.5.21022; SE 1.X)
Google browser output:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0
Write a public method call in the background (must be referenced)
Copy codeThe Code is as follows:
Public static int getBrowser ()
{
String BrowserInfo = HttpContext. Current. Request. UserAgent;
If (BrowserInfo. Contains ("MSIE 7.0 "))
{// IE7
Return 1;
}
Else if (BrowserInfo. Contains ("MSIE 6.0 "))
{// IE6
Return 2;
}
Else if (BrowserInfo. Contains ("Firefox "))
{// IE6
Return 3;
}
Else if (BrowserInfo. Contains ("Chrome "))
{// Google
Return 4;
}
Return 5;
}