compatibility and identification of browser with compatibility view

215 views Asked by At

I have an asp.NET application with multiview. I want something like that:

if(browser is IE8) view(1); else view(2);

I mean that: if I'm using internet explorer 8 I have the view 1; otherwise I want view 2.

I tried to use:

  • Request.UserAgent and setted view 1 if Request.UserAgent contains "MSIE 8"
  • search in System.Web.HttpBrowserCapabilities browser = Request.Browser; browser.Type/Version/MajorVersion/MSDomVersion/Browsers some property to identify the browser used to client.

The problem is that I can use it (one of the method above) only when compatibility view is not setted. Otherwise, the browser is always internet explorer 7 even if I'm using ie8 or ie11.

In this case, what can I do to identify the browser?

Thank you very much

1

There are 1 answers

3
Izzy On

This snippet of code is what I've used in the past and it's worked for me without an issue. However do bare in mind the string for the new IE 11 is returned as InternetExplorer instead of IE. So you can amend as required

if(Context.Request.Browser.Browser == "IE" && Context.Request.Browser.MajorVersion == 8)
 {
  //Do Something
 }