1

我为测试捆绑和缩小创建了一个 mvc4 应用程序,但是当我运行它并查看 html 呈现的代码时,我注意到没有我的 css 和 javascript 不是捆绑

<link href="/Content/themes/base/jquery.ui.resizable.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.selectable.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.accordion.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.autocomplete.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.button.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.dialog.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.slider.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.tabs.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.datepicker.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.progressbar.css" rel="stylesheet" type="text/css" />

<link href="/Content/themes/base/jquery.ui.theme.css" rel="stylesheet" type="text/css" />

<link href="/Content/site.css" rel="stylesheet" type="text/css" />

但默认情况下,Visual Studio 添加到我的布局文件中

   @Styles.Render("~/Content/themes/base/css", "~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

所以我想知道为什么css和javascript不是Bundle?

4

2 回答 2

2

我得到同样的东西。当我将 web.config 更改为此时:

<system.web>
    <compilation debug="false" targetFramework="4.5" />
    ...
</system.web>

...它反而呈现这个:

<link href="/Content/themes/base/css?v=ps9Ga9601PrzNA2SK3sQXlYmNW3igUv5FOdOPWptyus1"
    rel="stylesheet" type="text/css">
<link href="/Content/css?v=VvXiCiApDAv4OzD9Y7PEaTL0kONCWIV6Skw7uh51PZk1" 
    rel="stylesheet" type="text/css">
于 2012-06-27T13:02:41.040 回答
0
 BundleTable.EnableOptimization = true;

在 Global.asax.cs 的 Application_Start() 方法中添加这行代码。这将覆盖 web.config 中的任何设置并启用优化。有关详细信息,请参阅有关如何实现捆绑和缩小的视频教程

于 2016-02-09T18:25:46.053 回答