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
I've found a more elegant solution.
I'm using the Styles.RenderFormat(format, bundle)
.
I have a BundlesFormats
class with a property called PRINT
and I use it like so:
public class BundlesFormats
{
public const string PRINT = @"<link href=""{0}"" rel=""stylesheet"" type=""text/css"" media=""print"" />";
}
And in the cshtml:
@Styles.RenderFormat(BundlesFormats.PRINT, "~/bundles/Content/print")
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);
}
<link href="@cssMediaBundleUrl" rel="stylesheet" type="text/css" media="screen" />
Guess I can turn this into an Html helper, will do that later and edit.