ASP.NET Bundles how to disable minification ASP.NET Bundles how to disable minification asp.net asp.net

ASP.NET Bundles how to disable minification


Conditional compilation directives are your friend:

#if DEBUG            var jsBundle = new Bundle("~/Scripts/js");#else            var jsBundle = new ScriptBundle("~/Scripts/js");#endif


If you have debug="true" in web.config and are using Scripts/Styles.Render to reference the bundles in your pages, that should turn off both bundling and minification. BundleTable.EnableOptimizations = false will always turn off both bundling and minification as well (irrespective of the debug true/false flag).

Are you perhaps not using the Scripts/Styles.Render helpers? If you are directly rendering references to the bundle via BundleTable.Bundles.ResolveBundleUrl() you will always get the minified/bundled content.


To disable bundling and minification just put this your .aspx file(this will disable optimization even if debug=true in web.config)

vb.net:

System.Web.Optimization.BundleTable.EnableOptimizations = false

c#.net

System.Web.Optimization.BundleTable.EnableOptimizations = false;

If you put EnableOptimizations = true this will bundle and minify even if debug=true in web.config