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

后端 未结 8 1239
情深已故
情深已故 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:21

    Web Forms Solution

    In BundleConfig.cs:

    //Print css must be a separate bundle since we are going to render it with a media=print
    Bundles.Add(new StyleBundle("~/bundles/printCSS").Include("~/Content/Print.css"));
    

    Master Page:

    
    

    Master Page Code File:

    litCssPrint.Text = Styles.RenderFormat(@"", "~/bundles/printCSS").ToHtmlString();
    

提交回复
热议问题