c# - 如何将多个 ScriptBundle 捆绑到一个新的 ScriptBundle

标签 c# asp.net .net webforms bundling-and-minification

这是我目前所做的

bundles.Add(new ScriptBundle("~/bundles/WebformsJS").Include(
      "~/Scripts/WebForms/WebForms.js",
      "~/Scripts/WebForms/WebUIValidation.js",
      "~/Scripts/WebForms/MenuStandards.js",
      "~/Scripts/WebForms/Focus.js",
      "~/Scripts/WebForms/GridView.js",
      "~/Scripts/WebForms/DetailsView.js",
      "~/Scripts/WebForms/TreeView.js",
      "~/Scripts/WebForms/WebParts.js"));

bundles.Add(new ScriptBundle("~/bundles/MsAjaxJS").Include(
    "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));


bundles.Add(new ScriptBundle("~/bundles/MegaJS").
    .Include("~/bundles/WebformsJS")
    .Include("~/bundles/MsAjaxJS"));

然后我在 Site.Master 文件中渲染 MegaBundle,如下所示:

 <%: Scripts.Render("~/bundles/MegaJS") %> 

应用程序运行没有错误,但是当我查看页面源代码时,我可以看到包含

<script src="/bundles/MegaJS?v="></script>

如果你注意到版本是空白的,当我点击 bundle 脚本时它是空的

My questions are: 1) Does creating bundle from other bundle's is supported 2) If Yes! then is their an example I can follow.

最佳答案

不,目前您不能在 bundle 中包含 bundle ,您只能包含真实 Assets 。不过,这是我们 Assets 管理待办事项 list 上的内容。如果这是您想要的功能,您可以点赞 here .

关于c# - 如何将多个 ScriptBundle 捆绑到一个新的 ScriptBundle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13588447/

相关文章:

c# - 如何使用 WebListener 和 Windows 身份验证让我的 ASP.NET Core 应用程序托管在 IIS 下?

c# - BCrypt 是一种在 C# 中使用的好哈希算法吗?我在哪里可以找到它?

c# - 书中的短语 "The current SynchronizationContext is a property of the current thread"是否正确”?

ASP.NET MultiView 按 ID?

c# - 如何仅在 C# 中获取 RSACryptoServiceProvider 公钥和私钥

c# - 将 DLL 加载到单独的 AppDomain 中

c++ - Visual C++ .NET 中的多重继承

c# - 为什么此 WCF 服务一次只能处理一个请求?

c# - DataTable 的替代数据结构

c# - 更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性