简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM