我很困惑。我在这上面花了8个多小时。我已经构建了 Bootstrap 项目,默认的 ASP.Net 项目,默认的 MVC 4 项目。他们捆绑并工作。我无法将它纳入我的现场项目(MVC 4)。在页面源中,它指向一个捆绑包,但捆绑包似乎不存在。我已经使用 Global.asax.cs 中的 BundleTable.EnableOptimizations = true 强制它在调试环境中捆绑。我还把它作为一个版本发布到本地主机来解决这个问题。似乎没有其他人遇到过这个问题。我已经删除了通配符。我已验证所有文件都存在。
这是 BundleConfig.cs
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/css/trap.css",
"~/Content/themes/base/css/calendar.css",
"~/Content/themes/base/css/calendar_green.css",
"~/Content/themes/base/css/jquery-ui.css",
"~/Content/themes/base/css/reset.css",
"~/Content/themes/base/css/tables.css",
"~/Content/themes/base/css/media.css"
));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/css/css1.css"
));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-2.6.2.min.js"));
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.9.1.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui.js"));
bundles.Add(new ScriptBundle("~/bundles/indexjs").Include(
"~/Scripts/customform.js",
"~/Scripts/main.js",
"~/Scripts/calendar.js",
"~/Scripts/index.js"));
这些在 _Layout.cshtml
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/themes/base/css")
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
}
}
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/indexjs")
这是页面中的内容:
<link href="/Content/themes/base/css?v=7SpkiWgU-0qwm8o4vYF5hDEB6L_DnS5xvUSEa1JLYW81" rel="stylesheet"/>
<link href="/Content/css?v=fh8XEHnJaCFRna_3Cjrz3hjgz5VDfBkXTaNJ1ign4pk1" rel="stylesheet"/>
<script src="/bundles/jquery?v=UmEFuwJBr5PmaadGOBwoWrIxakg6oVbTduk0Gdne4ko1"></script>
<script src="/bundles/jqueryui?v=u5Tft1k7a-ZOfnV1Fz5TM1T_Rv33WbgFF-rZ8VWBtX01"></script>
<script src="/bundles/indexjs?v=1ATJu4VPSoZ_HPVcPlj-Te73BaXgxachLoR5Vxg0te81"></script>
我很困惑。我愿意接受任何建议。它只是行不通。