How to force BundleCollection to flush cached script bundles in MVC4

We hear your pain on documentation, unfortunately this feature is still changing quite fast, and generating documentation has some lag, and can be outdated almost immediately. Rick’s blog post is up to date, and I’ve tried to answer questions here as well to spread current info in the meantime. We are currently in the process … Read more

How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app

Update Version 1.1.x is available, read the release notes: https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization The Microsoft.Web.Optimization package is now obsolete. With ASP.NET (MVC) 4 and higher you should install the Microsoft ASP.NET Web Optimization Framework: Install the package from nuget: Install-Package Microsoft.AspNet.Web.Optimization Create and configure bundle(s) in App_Start\BundleConfig.cs: public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new … Read more

How can I specify an explicit ScriptBundle include order?

You could write a custom bundle orderer (IBundleOrderer) that will ensure bundles are included in the order you register them: public class AsIsBundleOrderer : IBundleOrderer { public virtual IEnumerable<FileInfo> OrderFiles(BundleContext context, IEnumerable<FileInfo> files) { return files; } } and then: public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { var bundle = new Bundle(“~/bundles/scripts/canvas”); … Read more

MVC4 StyleBundle not resolving images

According to this thread on MVC4 css bundling and image references, if you define your bundle as: bundles.Add(new StyleBundle(“~/Content/css/jquery-ui/bundle”) .Include(“~/Content/css/jquery-ui/*.css”)); Where you define the bundle on the same path as the source files that made up the bundle, the relative image paths will still work. The last part of the bundle path is really the … Read more