首页 > 解决方案 > Azure 不加载捆绑包

问题描述

我在 Visual Studio 中使用“Web API”模板启动了一个项目。然而,该项目开始增长,我需要建立一个网站。在本地运行时,所有功能都正确,但是我在 Azure 中发布站点后,无法识别 CSS 样式。

这是我的引导目录:

在此处输入图像描述

这是我的 Bundle 类的代码:

public static class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/Content/Scripts/jquery").Include(
                    "~/Content/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/Content/Scripts/modernizr").Include(
                    "~/Content/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/Content/Scripts/bootstrap").Include(
                  "~/Content/Scripts/bootstrap.js"));

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

主要布局如下:

<!DOCTYPE html>
<html>
<head>
  ...
  @Styles.Render("~/Content/css")
  @Scripts.Render("~/Content/Scripts/modernizr")
</head>
<body>
   <div class="container-fluid">
     ...
     @RenderBody()
     ...
   </div>
   @Scripts.Render("~/Content/Scripts/jquery")
   @Scripts.Render("~/Content/Scripts/bootstrap")
   <script src="~/Content/CustomScripts/Global.js"></script>
   @RenderSection("scripts", required: false)
</body>
</html>

以下类似的问题(link1 y link2)提到有必要更改 Bundle 存档名称,但是当我发布到 Azure 时它不起作用;但是,如前所述,它在本地可以正常工作。

标签: c#asp.net-mvcazureasp.net-web-apibootstrap-4

解决方案


推荐阅读