C# MVC - 当优化设置为 true 时样式不呈现

C# MVC - Styles not rendering when optimizations are set to true

我在Config.cs中有以下代码:

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-2.2.3.min.js",
                    "~/Scripts/jquery.validate.min.js",
                    "~/Scripts/jquery.validate.unobtrusive.min.js",
                    "~/Scripts/jquery.unobtrusive-ajax.min.js"
                    ));
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));
        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"
                  ));
        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/font-awesome.min.css",
                  "~/Content/css/site.css", 
                  "~/Content/css/ab-style.css"));

样式未正确呈现,page看起来很奇怪。但是当我在 config.cs 中设置 BundleTable.EnableOptimizations = false 时一切正常。有没有人知道为什么会这样。

注意:Web.config中没有Debug="true",因为没有"~/bundles/jquery","~[=22=,所以不存在虚拟路径冲突]" ...我项目中的文件夹。

在虚拟文件夹中创建您的包。

  bundles.Add(new StyleBundle("~/Content/css/AllMyCss.css").Include(
              "~/Content/bootstrap.css",
              "~/Content/font-awesome.min.css",
              "~/Content/css/site.css", 
              "~/Content/css/ab-style.css"));

并使用以下代码呈现一个包

@Styles.Render("~/content/css/AllMyCss.css")