2

Currently I've got the following code in my BundleConfig.cs:

 bundles.Add(new StyleBundle("~/Content/css").Include(
                        "~/Content/site.css",
                        "~/Content/ie8.css"
                        ));

Obviously, I only want the "ie8.css" stylesheet to be displayed for IE8. I can do this quite easily by taking this out of my BundleConfig.cs file and adding the standard HTML tags to achieve this in my Layout Views.

However, I'm wondering if there's any way to achieve this same result in the BundleConfig.cs file and keep the file auto-minification? I'm guessing the code-behind doesn't know anything about the user's browser so it isn't possible, but figured I'd ask some of the experts out there!

Chris Dixon
  • 9,147
  • 5
  • 36
  • 68
  • Somebody has a (not awful) solution here: http://stackoverflow.com/questions/13039792/how-to-bundle-specific-css-according-to-browser-version – paul May 01 '13 at 08:55
  • That question is exactly what I was getting at - I couldn't find that when I had a search around! Thank you, that concluded my theories. – Chris Dixon May 01 '13 at 08:56

2 Answers2

2

I don't think the framework provides for variant based bundles. It is global all or nothing. You could make various bundles per browser.

Andrew Beal
  • 427
  • 8
  • 23
0

I've only got round this by adding custom css overriding the required styles in the normal was with the IF browser checks.

Mathew Padley
  • 102
  • 1
  • 8