0

This is how I include JavaScript files in my ASP.NET MVC application,

Bundles.Add(new ScriptBundle(ConfigBundles.Scripts).Include
(
    "~/Content/Scripts/Libraries/framework-{version}.js",
    "~/Content/Scripts/Libraries/controls-{version}.js"
));

My understanding is that whenever I do a new release where the referenced JavaScript files have changed, i just need to increment the version number so that user's web browsers know that they need to clear the existing cache and request the new file.

However, this same process does not seem to work for stylesheets - this is how I load them:

Bundles.Add(new StyleBundle(ConfigBundles.Styles)
    .Include("~/Content/Styles/Site-{version}.css", new CssRewriteUrlTransform()));

However, this does not seem to work - when I change the name of the Site.css to include a version, the bundling doesn't seem to detect it. Furthermore, in most guides on bundling they just talk about using this feature with Scripts - I haven't seen anyone confirm that it can used with styles as well...

Am I going about this the right way?

William
  • 3,335
  • 9
  • 42
  • 74
  • did you enable optimizations?? ` BundleTable.EnableOptimizations = true;` – Tavitos Jul 18 '16 at 19:54
  • That is enabled by default when code is released and disabled in development correct? How would enabling it impact my situation? – William Jul 18 '16 at 20:40
  • Bundling and minification is enabled or disabled by setting the value of the debug attribute in the compilation Element in the Web.config file... it might be overriding your bundling settings. also check the following... [link](http://stackoverflow.com/questions/29254181/bundling-not-working-in-mvc5-when-i-turn-on-release-mode) – Tavitos Jul 18 '16 at 21:05

0 Answers0