vb.net 即使在调试模式下,在 WebForms 中使用包也会输出缩小/组合的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16069989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:18:03  来源:igfitidea点击:

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

asp.netvb.netwebformsweb-optimization

提问by CBarr

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

我创建了一组各种脚本文件,我想将它们组合/缩小在一起。在隐藏文件我的代码(是的,对不起,这是在VB!)我将它添加到<asp:placeholder /><head>这样的

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.

这会起作用,但它似乎总是输出压缩的缩小版本,即使debug="true"在 Web.Config 中也是如此。

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

无论如何,这就是输出: <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 = falseand it stilloutputs the single minified script tag. I'm out of ideas.

我还尝试手动设置该选项BundleTable.EnableOptimizations = false,但它仍然输出单个缩小的脚本标记。我没主意了。



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!

我正在用一些相关的代码做一些非常愚蠢的事情,但从技术上讲,捆绑包的所有内容都很好并且工作正常。问题为我解决!

回答by Marco Ramires

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

我建议您安装 Microsoft.AspNet.WebOptimization.WebForms。它真的很好用。

Microsoft.AspNet.WebOptimization.WebForms

Microsoft.AspNet.WebOptimization.WebForms

Then you can use:

然后你可以使用:

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