Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

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.

question from:https://stackoverflow.com/questions/12533591/why-are-my-style-bundles-not-rendering-correctly-in-asp-net-mvc-4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...