Using bundles in WebForms outputs the minified/combined file even in debug mode

前提是你 提交于 2019-12-10 13:33:05

问题


I've created a bundle of various script files that I want to be combined/minified together. In my code behind file (yes, sorry it's in VB!) I add it to a <asp:placeholder /> on the <head> like this

Me.PlhHeader.Controls.Add(New LiteralControl(Scripts.Render("~/bundles/main").ToHtmlString()))

This will work, but it always seems to output the compressed minified version, even when debug="true" in the Web.Config.

no matter what, this is what is output: <script src="/bundles/main"></script>

What do I need to do differently to make this output the individual uncompressed files when in debug mode?


EDIT

I've also tried to manually set the option BundleTable.EnableOptimizations = false and it still outputs the single minified script tag. I'm out of ideas.


Final Edit

I was doing something very dumb with some related code, but technically everything with the bundles was fine and working correctly. Problem solved for me!


回答1:


I would recommend you to install the Microsoft.AspNet.WebOptimization.WebForms. It works really well.

Microsoft.AspNet.WebOptimization.WebForms

Then you can use:

<%: System.Web.Optimization.Scripts.Render("~/bundles/main") %>


来源:https://stackoverflow.com/questions/16069989/using-bundles-in-webforms-outputs-the-minified-combined-file-even-in-debug-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!