【问题标题】:ASP.NET MVC Bundling wrong Bootstrap versionASP.NET MVC Bundling 错误的 Bootstrap 版本
【发布时间】:2016-12-10 15:41:17
【问题描述】:

我有一个问题,即生产中的 MVC4 中的捆绑以某种方式捆绑了我的项目中不再拥有的旧版本的 Bootstrap。

我更新了 Bootstrap 的版本,因为我想使用一些我项目中旧版本不支持的 Glyphicons。

在本地以调试或发布模式运行,所有 Glyphicon 都按预期显示,但一旦部署到生产环境(使用 msbuild 部署到 Azure Web App),新的 Glyphicon 将丢失,并且缩小 + 捆绑的 css 文件丢失对较新的 Gyphicons 的引用 - 它本质上是 bootstrap.css 的旧版本

这是我的 RegisterBundles 方法:

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.UseCdn = false;

        // Clear out the list and add back the ones we want to ignore.
        // Don't add back .debug.js.
        bundles.IgnoreList.Clear();
        bundles.IgnoreList.Ignore("*-vsdoc.js");
        bundles.IgnoreList.Ignore("*intellisense.js");

        bundles.Add(new StyleBundle("~/style/global").Include(
            "~/Content/css/lib/bootstrap.css",
            "~/Content/css/global.css"));
    }

那我用...

@Styles.Render("~/style/global")

包含样式。

【问题讨论】:

  • 您能否确认您的 Azure Web 应用中确实存在较新的版本?
  • 是的,如果我点击 /Content/css/lib/bootstrap.css 新版本确实会下载。
  • 作为一个实验试试这个:bundles.ResetAll(); BundleTable.EnableOptimizations = false;bundles.Add(...)之前
  • 今晚才能测试部署,但我会尝试然后报告。谢谢。
  • 这行得通,但是设置 EnableOptimizations = false 显然会阻止它捆绑,所以它只是提供原始 css 文件。

标签: asp.net-mvc twitter-bootstrap asp.net-mvc-4 bundling-and-minification


【解决方案1】:

使用ResetAll() 方法清除和重置。更多相关信息here

【讨论】:

    【解决方案2】:

    我有一个类似的问题,我的ASP.NET MVC 5 应用程序仍在使用旧版本的bootstrap.css (3.0),即使我从项目中删除了旧的 bo​​otstrap.css 文件并安装了Bootstrap 3.3.7 NuGet 包。当我运行应用程序并从浏览器执行“查看页面源代码”,然后单击 "/Content/bootstrap.css" rel="stylesheet" 链接时,它 STILL 提出了旧的 bo​​otstrap.css 文件内容。

    我困惑并搞砸了一个多小时,直到我意识到 css 页面被缓存了。我想通了,因为当我点击 "/Content/bootstrap.css “ rel="stylesheet" 链接打开bootstrap.css 然后刷新页面,它更改为我的 3.3.7 版本。

    无论如何,我决定发布此回复,因为它可能会帮助其他人了解问题可能是由于缓存造成的。

    【讨论】:

      猜你喜欢
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      • 2016-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多