我正在使用主页/内容页面在asp.net中开发。我正在使用Bundling将其添加到母版页面。我想我的一切设置正确;但是,当我正在开发时,如果我正在尝试设置html,我就再也看不到内容页面上的可用类列表......如果没有捆绑用于弹出的类列表到达class = part;但捆绑没有出现。
我的设置如下所示,在Master页面中我引用了这些包:
<head runat="server">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%: Page.Title %> - JCPS DMC</title>
<link href="~/favicon.ico" rel="shortcut icon" />
<asp:PlaceHolder ID="PlaceHolder2" runat="server">
<%: Styles.Render("~/bundles/bootstrapCSS", "~/bundles/utilitiesCSS") %>
<%: Scripts.Render("~/bundles/utilitiesJs", "~/bundles/modernizr") %>
</asp:PlaceHolder>
<asp:ContentPlaceHolder ID="contentHeader" runat="server">
</asp:ContentPlaceHolder>
</head>
我的BundleConfig.cs文件如下所示:
using System.Web.Optimization;
namespace DMC
{
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254726
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include(
"~/Scripts/WebForms/WebForms.js",
"~/Scripts/WebForms/WebUIValidation.js",
"~/Scripts/WebForms/MenuStandards.js",
"~/Scripts/WebForms/Focus.js",
"~/Scripts/WebForms/GridView.js",
"~/Scripts/WebForms/DetailsView.js",
"~/Scripts/WebForms/TreeView.js",
"~/Scripts/WebForms/WebParts.js"));
bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
"~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));
bundles.Add(new ScriptBundle("~/bundles/utilitiesJs").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/bootstrap.js",
"~/Scripts/common.js",
"~/Scripts/analytics.js"));
bundles.Add(new ScriptBundle("~/bundles/highCharts").Include(
"~/Scripts/highcharts/4.2.0/highcharts.js",
"~/Scripts/highcharts/4.2.0/highcharts-more.js",
"~/Scripts/highcharts/4.2.0/highcharts-3d.js",
"~/Scripts/highcharts/4.2.0/modules/broken-axis.js",
"~/Scripts/highcharts/4.2.0/modules/data.js",
"~/Scripts/highcharts/4.2.0/modules/drilldown.js",
"~/Scripts/highcharts/4.2.0/modules/exporting.js",
"~/Scripts/highcharts/4.2.0/modules/funnel.js",
"~/Scripts/highcharts/4.2.0/modules/heatmap.js",
"~/Scripts/highcharts/4.2.0/modules/no-data-to-display.js",
"~/Scripts/highcharts/4.2.0/modules/offline-exporting.js",
"~/Scripts/highcharts/4.2.0/modules/solid-gauge.js",
"~/Scripts/highcharts/4.2.0/modules/treemap.js",
"~/Scripts/highcharts/4.2.0/adapters/standalone-framework.js"
));
// Use the Development version of Modernizr to develop with and learn from. Then, when you’re
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/bundles/bootstrapCSS").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-multiselect.css",
"~/Content/bootstrap-navbar.css",
"~/Content/bootstrap-overrides.css"));
bundles.Add(new StyleBundle("~/bundles/utilitiesCSS").Include(
"~/Content/print.css",
"~/Content/common.css",
"~/Content/site.css",
"~/Content/colorThemes.css"));
BundleTable.EnableOptimizations = false;
}
}
}
我认为BundleConfig.cs文件中的最后一行是调试的关键:
BundleTable.EnableOptimizations = false
我认为如果将其设置为false,它会覆盖web.config文件并允许您查看类名...这是不正确的?我错过了别的什么吗?
答案 0 :(得分:0)
以下是该属性的文档:BundleTable.EnableOptimizations Property。启用它会捆绑和缩小您的脚本/ css文件,有关完整的详细信息,请参阅Bundling and Minification。这为您的客户提供了更快的加载时间,因为通过线路传输的数量较少(较少的空白区域,换行等)。它使客户端脚本调试更加困难,因为整个脚本可以在一行上,并且javascript中的变量名通常也会缩短。它与服务器端代码或web.config无关。
答案 1 :(得分:0)
没有。你没有遗漏任何东西。根据MSDN,您也可以使用,
naam
文档明确指出,
除非EnableOptimizations为true或者调试属性为 编译Web.config文件中的元素设置为false,文件 不会捆绑或缩小。
链接:http://www.asp.net/mvc/overview/performance/bundling-and-minification