gpt4 book ai didi

c# - 捆绑和缩小错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:18:39 25 4
gpt4 key购买 nike

我知道捆绑和缩小只有在不处于 Debug模式时才有效。

<compilation debug="false" targetFramework="4.5"/>

如果我按 Ctrl + F5 运行我的 SPA,它工作正常。

但是,如果我按 F5 启用调试,即使 web.config 上的 debug=false 时,我的页面也不会加载正确。当我检查开发者工具时,I found this .

如果我检查我的代码和脚本库,似乎没问题。

BundleConfig.cs:

public static void RegisterBundles(BundleCollection bundles)
{
bundles.IgnoreList.Clear();
AddDefaultIgnorePatterns(bundles.IgnoreList);

bundles.Add(
new ScriptBundle("~/scripts/modernizr")
.Include("~/scripts/modernizr-{version}.js"));

bundles.Add(
new ScriptBundle("~/scripts/vendor")
.Include("~/scripts/jquery-{version}.min.js")
.Include("~/scripts/bootstrap.min.js")
.Include("~/scripts/knockout-{version}.js")
.Include("~/scripts/toastr.js"));

bundles.Add(
new StyleBundle("~/Content/css")
.Include("~/Content/ie10mobile.css") // Must be first. IE10 mobile viewport fix
.Include("~/Content/bootstrap.min.css")
.Include("~/Content/bootstrap-responsive.min.css")
.Include("~/Content/font-awesome.min.css")
.Include("~/Content/toastr.css")
.Include("~/Content/styles.css")
);
}

和VS studio结构,files are there .

如果我检查我的 index.cshtml

@using System.Web
@using System.Web.Optimization
<!DOCTYPE html>
<html>
<head>
<title>CCJS</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
@Styles.Render("~/Content/css")
<script language="javascript">
// Must be first. IE10 mobile viewport fix
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
var mq = "@@-ms-viewport{width:auto!important}";
msViewportStyle.appendChild(document.createTextNode(mq));
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
</script>
@Scripts.Render("~/scripts/modernizr")
</head>
<body>
<div id="applicationHost">
@RenderPage("_splash.cshtml")
</div>

@Scripts.Render("~/scripts/vendor")
<script src="~/Scripts/require.js" data-main="App/Main"></script>
</body>
</html>

最佳答案

您可以将此行添加到您的 BundleConfig.cs

//note: you can map isCompressionEnabled to your webconfig appSettings
BundleTable.EnableOptimizations = isCompressionEnabled;

关于c# - 捆绑和缩小错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25161194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com