How to disable Javascript/CSS minification in ASP.NET MVC 4 Beta

前端 未结 10 1332
暗喜
暗喜 2020-12-09 10:17

I am just trying out ASP.NET MVC 4 but I can\'t figure out how to disable Javascript/CSS minification feature. Especially for development environment this will help greatly

10条回答
  •  北海茫月
    2020-12-09 11:01

    After the call to EnableDefaultBundles() in Global.asax, you can do this ...

            if ( ... running in development environment ...)
            {
                var registeredBundles = BundleTable.Bundles.GetRegisteredBundles();
                foreach (var bundle in registeredBundles)
                {
                    if (bundle.Transform is System.Web.Optimization.JsMinify)
                        bundle.Transform = new NoTransform();
                }
            }
    

    Not pretty (modifying state set by the system), but it's a lot less code than all the other suggestions, still lets you use the standard bundling behavior and it doesn't involve any changes to your views.

提交回复
热议问题