When deploying my MVC application, the .NET 4.5 framework is bundling & minifying my CSS. However, the resultant file is empty, therefore the CSS rules are not applied. In Chrome, I get a Resource interpreted as Stylesheet but transferred with MIME type text/plain
warning. In IE9, I get a CSS was ignored due to mime type mismatch
warning.
This is what's in my BundleConfig
bundles.Add(
new StyleBundle("~/Content/bootstrap").Include(
"~/Content/bootstrap/bootstrap-responsive.css",
"~/Content/bootstrap/bootstrap-editable.css",
"~/Content/bootstrap/FileUpload.css"));
Here is my Layout head:
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=Edge" />
<title>@ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
<link href="@ViewBag.StyleUrl" rel="stylesheet" type="text/css" />
@Styles.Render("~/Content/bootstrap")
<script src="~/scripts/libs/modernizr/modernizr-2.5.3.js" type="text/javascript"></script>
</head>
The extra stylesheet is for a dynamically loaded stylesheet based on config in our Admin tool.
When I run this locally, or if I set debug="true", then I get my individual files & everything looks as it should. If I hardcode these in to my Layout page, they display fine. I've checked IIS & see the correct MIME type for CSS (which makes sense given that hardcoded values work). I've also checked to make sure the "Static Content" role service is installed, as I came across that in my googling as well.
Any thoughts?
The bundle name is the same as the folder name on the filesystem,
Change your bundle to
bundles.Add(
new StyleBundle("~/Content/bootstrapBundle").Include(
"~/Content/bootstrap/bootstrap-responsive.css",
"~/Content/bootstrap/bootstrap-editable.css",
"~/Content/bootstrap/FileUpload.css"));
i.e. so the name of the bundle is NOT the name of a folder or file
Had the same problem. My solution was the invalid name of bundle (it consisted of '_' or '.'). The name needs to be plain text:
bundles.Add(
new StyleBundle("~/Content/bootstrap_Bundle").Include(
"~/Content/bootstrap/bootstrap-responsive.css",
"~/Content/bootstrap/bootstrap-editable.css",
"~/Content/bootstrap/FileUpload.css"));
had to be:
bundles.Add(
new StyleBundle("~/Content/bootstrapBundle").Include(
"~/Content/bootstrap/bootstrap-responsive.css",
"~/Content/bootstrap/bootstrap-editable.css",
"~/Content/bootstrap/FileUpload.css"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With