Andre Lombaard
Andre Lombaard

Reputation: 7105

Can't get bundling and minification to work on MVC4

I'm trying to bundle and minify my css and js files with a MVC4 application but can't get it to work. I installed the Microsoft.Web.Optimization package making use of the package manager console.

I included the following statement in my HTML

<link rel="stylesheet" href="Styles/Layout/CSS" />

But my stylesheets are not loading. Is there anything I'm missing?

Upvotes: 0

Views: 249

Answers (1)

Richard Dalton
Richard Dalton

Reputation: 35793

Assuming you've setup that bundle in BundleConfig.cs in your App_Start folder then you should just need to add this line in your _layout.cshtml:

 @Styles.Render("~/Styles/Layout/CSS") 

The path of the bundle should be the same as in the BundleConfig.cs file

If you don't have a BundleConfig.cs file then the easiest thing to do is create a new MVC application project (internet application template) and follow the example there.

Upvotes: 3

Related Questions