在MVC中捆绑CSS和JS。为什么我不能让它工作?

时间:2013-07-08 21:54:00

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

我很困惑。我在这上花了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>

我很困惑。我对任何建议持开放态度。它只是不起作用。

0 个答案:

没有答案