Make ASP.NET bundling specify media=screen for CSS bundle

后端 未结 8 1266
情深已故
情深已故 2020-12-23 13:47

I\'m just trying out ASP.NET 4.5 bundling and minification, and ran into an issue.

I\'ve got around 10 css files, of which 2 were originally referenced in the layout

8条回答
  •  暖寄归人
    2020-12-23 14:36

    Well, it's an ugly hack, but hopefully the team will add a built-in way to do it in the next release.

    This is how I solved it, maintaining the caching string and still being able to add the media attribute to the tag.

    @{
        var cssMediaBundleUrl = BundleTable.Bundles.ResolveBundleUrl("~/stylesheets/mediacss", true);
    }
    
    

    Guess I can turn this into an Html helper, will do that later and edit.

提交回复
热议问题