In your Controller you could inspect the UserAgent property of the Request.
HttpContext.Current.Request.UserAgent
Full code example:
private const string IEUserAgent = "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)";
public ActionResult Index()
{
string userAgent = HttpContext.Current.Request.UserAgent;
if (userAgent == IEUserAgent)
{
return View("IE9View");
}
return View();
}
You may want to encapsulate the UserAgent string(s) in a constants file which would serve a more appropriate place rather than at the Controller level.
An alternative approach would be to use a DisplayModeProvider within the Global.asax
DisplayModeProvider.Instance.Modes.Insert(1, new DefaultDisplayMode("IE9")
{
ContextCondition = (ctx => ctx.GetOverriddenUserAgent()
.IndexOf("MSIE 9", StringComparison.OrdinalIgnoreCase) > 0)
});
You would then create a Index.IE9.cshtml file within your View section of your application containing the markup to be displayed to users utilising Internet Explorer 9.