Barrosy
Barrosy

Reputation: 1457

CSS Handling in MVC

Layout page in my MVC project displays the following code:

@Styles.Render("~/Content/css")

I also read that this will ask for the files defined in the RegisterBundles method (in the BundleConfig class in the App_Start folder to be precise).

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

But somehow my changes in Content/bootstrap.css won't go through. My MVC project only renders the Content/bootstrap.min.css, only changes in that file will change the styling of my MVC project. Can anyone explain me or direct me somewhere I can read about how changing CSS code in MVC works? Is it necessary to always change the bootstrap.min.css? I thought there must be some other way to change CSS code.

Upvotes: 1

Views: 52

Answers (2)

SmartDev
SmartDev

Reputation: 2862

You can add this line:

BundleTable.EnableOptimizations = false;

in the Application_Start() of your Global.asax.cs file. This will disable the automatic using of the minimized files.

You can see more about this from here.

Upvotes: 1

Curtis
Curtis

Reputation: 103338

ASP.NET Bundling will use a min.css file if it exists as this is quicker for on-the-fly bundling as no dynamic minification is required.

Therefore either remove your .min.css file, or ensure this is updated whenever your .css file is.

Upvotes: 3

Related Questions