通过 ASP.NET 4.5 WebForms 中的 bundle.config 与 BundleConfig.cs 捆绑资源 [英] Bundling resources via bundle.config vs BundleConfig.cs in ASP.NET 4.5 WebForms

查看:18
本文介绍了通过 ASP.NET 4.5 WebForms 中的 bundle.config 与 BundleConfig.cs 捆绑资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 ASP.NET 4.5 的新 System.Web.Optimization/Microsoft.AspNet.Web.Optimization:

Regarding ASP.NET 4.5's new System.Web.Optimization / Microsoft.AspNet.Web.Optimization:

谁能解释一下使用 BundleConfig.cs 类文件与 bundle.config xml 文件在使用捆绑资源方面的区别?

Can anyone explain the difference in the use of bundling resources using the BundleConfig.cs class file as opposed to the bundle.config xml file?

我看过一些文章 在 BundleConfig.cs 中显示了 js 和 css 的捆绑,而 others 显示了 BundleConfig.cs 中的 js 和 bundle.config 中的 css.

I've seen some articles showing bundling both js and css in BundleConfig.cs, while others showing bundling js in BundleConfig.cs and css in bundle.config.

我想我不明白 #1) 为什么你不会为了简单起见只用一种特定的方式来做它们 - 以及 #2) 为什么有人更喜欢在类文件中对这样的资源进行硬编码?将它们放在一个 xml 文件中似乎是一种更加动态的方法,如有必要,该文件可以即时更改.

I guess I don't understand #1) why you wouldn't just do them both one particular way for simplicity - and #2) why anyone would prefer to hard-code resources like that in a class file? It seems like a much more dynamic approach to just put them in an xml file that can be changed on-the-fly if necessary.

似乎更多的文章实际上倾向于使用 BundleConfig.cs,而不是其他任何东西.有什么特别的利弊鼓励这种做法吗?

It seems like more articles actually lean toward using BundleConfig.cs than anything else. Is there some particular pro or con that encourages this?

另外,如果有关于 System.Web.Optimization 的真实文档,我很想知道位置(因为我肯定找不到).

Also, if there is any real documentation on System.Web.Optimization, I would love to know the location (because I sure can't find it).

谢谢-

推荐答案

这个文档比我以往任何时候都更好地解释了这一切

this documentation explains it all better than I ever could

http://www.asp.net/mvc/教程/mvc-4/捆绑和缩小

最好的事情之一是:

捆绑框架遵循几个常见的约定,例如:

The bundling framework follows several common conventions such as:

当FileX.min.js"和FileX.js"时选择.min"文件发布存在.

Selecting ".min" file for release when "FileX.min.js" and "FileX.js" exist.

选择非.min"版本进行调试.忽略-vsdoc"文件(例如 jquery-1.7.1-vsdoc.js),仅由智能感知.

Selecting the non ".min" version for debug. Ignoring "-vsdoc" files (such as jquery-1.7.1-vsdoc.js), which are used only by IntelliSense.

这篇关于通过 ASP.NET 4.5 WebForms 中的 bundle.config 与 BundleConfig.cs 捆绑资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆