【问题标题】:How to use ASP.NET 4.5 Bundling & a CDN to get Bootstrap 3.2?如何使用 ASP.NET 4.5 捆绑和 CDN 来获取 Bootstrap 3.2?
【发布时间】:2016-06-11 06:29:59
【问题描述】:

我是一名新的 ASP.NET 开发人员,我正在尝试使用 ASP.NET 4.5 的最大功能之一,即捆绑功能。它似乎对使用 CDN 有一些支持。我现在正在努力使用捆绑来获取引导程序 3.2.0。 那我该怎么做呢?

这是我的代码的 sn-p:

public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.UseCdn = true;   //enable CDN support

            //add link to jquery on the CDN
            var cssCdnPath = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css";

            bundles.Add(new StyleBundle("~/bundles/css",
                      cssCdnPath).Include(
                      "~/Assets/css/bootstrap-{version}.css"));
}

【问题讨论】:

    标签: c# asp.net twitter-bootstrap-3 webforms asp.net-optimization


    【解决方案1】:

    CDN 位置仅在 BundleTable.EnableOptimizations 配置为 true 时使用。

    简单地将以下内容添加到 RegisterBundles 方法中:

    BundleTable.EnableOptimizations = true;

    【讨论】:

      猜你喜欢
      • 2012-11-02
      • 2013-05-26
      • 2013-03-09
      • 2021-08-31
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2017-09-20
      • 2013-09-11
      相关资源
      最近更新 更多