I'm using MVC4 StyleBundle
to bundle up a bunch of CSS. There is one CSS that's only needed for IE 9 or lower.
In my BundleConfig
class of RegisterBundles
method, I have:
if (HttpContext.Current.Request.Browser.Browser.Trim().ToUpperInvariant().Equals("IE") && HttpContext.Current.Request.Browser.MajorVersion <= 9)
cssBundle.Include("~/Content/ie.css");
But then I got a Request is not available in this context
error. Is it not possible to detect browsers during RegisterBundles
method?