Scripts.Render using outdated javascript file

前端 未结 1 1078
梦如初夏
梦如初夏 2020-12-11 10:26

My MVC4 application is using Scripts.Render to load a bundle that is loading a file called \"functions.js.\"

When I debug this application in the browse

相关标签:
1条回答
  • 2020-12-11 10:44

    This is likely a caching issue. When using Bundling and Minification in debug mode (when <compilation debug="true" /> is set in your web.config), bundling/minification is disabled.

    You can override this and force bundling and minification by adding BundleTable.EnableOptimizations = true;. This will make it act like it will in your production environment, where everything is bundled and minified, and the script reference includes that versioning parameter (like you gave) that will force the browser to reload your scripts when anything changes.

    public class BundleConfig
    {
        public static void RegisterBundles(BundleCollection bundles)
        {
            //all your bundle code
            BundleTable.EnableOptimizations = true;
        }
    }
    
    0 讨论(0)
提交回复
热议问题