5

I am looking how to detect IE7 and IE8 browser in MVC4, how to do that?

I find the property Request.Browser but it do not gives any information about browser.

2 Answers 2

10

I advise you to use Contains method on Request.UserAgent

if (Request.UserAgent.Contains("MSIE 7.0"))
{
    // Internet Explorer 7
}
else if (Request.UserAgent.Contains("MSIE 8.0"))
{
    // Internet Explorer 8
}
Sign up to request clarification or add additional context in comments.

1 Comment

This is what I get from Request.Headers["User-Agent"]: "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"
0

Another option if you want <= 8:

Request.Browser.Browser == "IE" && Request.Browser.MajorVersion <= 8;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.