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

查看:84
本文介绍了通过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,而

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),仅由 IntelliSense.

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天全站免登陆