Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my style bundles not rendering correctly in ASP.NET MVC 4?

So I am new to ASP.NET MVC 4 (well, I used 3 a little).

Anyway, in my BundleConfig.cs file, I am trying to load the Twitter Bootstrap css files and an additional site.css file.

But only the site.css file is rendered. I have confirmed that the bootstrap css files are indeed in the right place (Content folder) and are in the same location as the site.css

bundles.Add(new StyleBundle("~/Content/css").Include(             "~/Content/bootstrap.min.css",             "~/Content/bootstrap-responsive.min.css",             "~/Content/site.css")); 

EDIT

OK, this isn't my preferred way but Andrei Drynov recommended I try:

@import url("bootstrap.min.css") body{background: #e8e6da;padding-top:60px;padding-bottom:40px;} @import url("bootstrap-responsive.min.css") 

But that doesn't work. I changed the site.css to the above but now the background body color doesn't even work. If I remove the @imports the background is the correct color.

EDIT 2

I don't get it but adding:

bundles.IgnoreList.Clear(); 

To my bundles file fixed it. Hmmm. Not sure I understand. But I was able to remove the @imports out of the site.css.

Strange.

like image 667
cbmeeks Avatar asked Sep 21 '12 15:09

cbmeeks


People also ask

What must be done to enable bundling and minification?

Bundling and minification is enabled or disabled by setting the value of the debug attribute in the compilation Element in the Web. config file. In the following XML, debug is set to true so bundling and minification is disabled. To enable bundling and minification, set the debug value to "false".

How does bundling work in MVC?

Bundling is one of the features of MVC. By implementing this, we can improve performance request load time. Minification is the process of removing unnecessary data without changing its functionality such as removing white spaces, comments, converting the large variable names to small, etc.

Can we use bundling and minification with ASP NET web forms like MVC?

To optimize the performance of an application I found that bundling and minification can significantly improve the performance. It can be applied on MVC as well as in ASP.NET web forms.

What are the two types of bundles in MVC 5?

Bundle Types ScriptBundle: ScriptBundle is responsible for JavaScript minification of single or multiple script files. StyleBundle: StyleBundle is responsible for CSS minification of single or multiple style sheet files.


1 Answers

The default behaviour is for the IgnoreList to ignore any minified scripts.

You can either remove the '.min' from their names, or clear the IgnoreList.

like image 130
paul Avatar answered Sep 28 '22 03:09

paul