Reputation: 235
I am creating a style bundle:
bundles.Add(new StyleBundle("~/content/bundled-styles.css").Include(
"~/content/flexisel-style.css"));
... and in my view:
@Styles.Render("~/content/bundled-styles.css")
If I view my page without optimizations enabled (i.e. BundleTable.EnableOptimizations = false;
) then everything works fine. My .css file gets added to the page without any problems and it contains all the styles.
If I set BundleTable.EnableOptimizations = true;
(without changing anything else) then the generated .css bundle doesn't contain any styles. The bundled .css file is added to the page along with the generated token but when I click on the .css file from the page source, it is completely blank. My page then is obviously rendered without any styling.
Additional information:
Upvotes: 5
Views: 3240
Reputation: 5623
I was stuck on this for a very long time, i was trapped by the following:
that if the key you’re using for your bundle, in this case “~/scripts”, matches the virtual path of the file included in the bundle, then it will not be included. To fix this, I changed the key to “~/bundles/scripts” and everything is happy now.
Credits: https://samrueby.com/2015/03/05/asp-net-mvc-bundleconfig-scripts-returning-an-empty-response/
Upvotes: 3
Reputation: 7254
I just had this issue as well. It seems as if the bundler did not like the extension in the name. Once I removed the extension, the bundler started to work.
You might try doing the following. Notice I've removed the .css
in two places.
Remove the .css
bundles.Add(new StyleBundle("~/content/bundled-styles").Include(
"~/content/flexisel-style.css"));
@Styles.Render("~/content/bundled-styles")
Upvotes: 5