I have the following code which reads the userAgent and does some logic based on the values matched using indexOf:
String userAgent;
userAgent = Request.UserAgent;
// If it's not IE
if (userAgent.IndexOf("MSIE") < 0)
{
return RedirectToAction("Index", "Home", new { area = "Dashboard" });
}
// If it's IE BUT ChromeFrame
else if(userAgent.IndexOf("ChromeFrame") > -1)
{
return RedirectToAction("Index", "Home", new { area = "Dashboard" });
}
// It's just IE
else
{
return View("ChromeFrame");
}
If it's IE then it should return the view or if its IE but contains ChromeFrame then it should redirect and it's another browser then it should redirect as well.
I think the problem is with the > 0
part of the code. What is the correct way of comparing info? Thanks.