gpt4 book ai didi

c# - ASP.Net MVC 5 子目录捆绑问题

转载 作者:太空狗 更新时间:2023-10-29 17:44:43 24 4
gpt4 key购买 nike

我在我的 ASP.Net MVC 5 项目中发现了一个奇怪的捆绑行为。当我在 BundleConfig.cs 文件中显式声明所有文件时,我的项目工作正常,如下所示:

bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/app/app.js",
"~/app/config.js",
"~/app/dir1/file1.js",
"~/app/dir1/subdir1/file2.js",
.....

但是,如果我改为使用 IncludeDirectory,则开发期间的脚本路径 (BundleTable.EnableOptimizations = false) 是不完整的。这是我看到的:

bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/app/app.js",
"~/app/config.js")
.IncludeDirectory("~/app/dir1", "*.js", true)

Chrome 在尝试获取 file2.js 时显示 404。捆绑系统将以下内容添加到我的布局页面:

<script src="/app/app.js"></script>
<script src="/app/config.js"></script>
<script src="/app/dir1/file1.js"></script>
<script src="/app/dir1/file2.js"></script>

file2.js 路径错误。它省略了路径的 subdir1 部分。我在这里遗漏了什么吗?

最佳答案

这是 1.1.1 版的已知问题。升级软件包(或降级到 1.1.0),它应该可以解决您的问题。

Web Optimization path issue while in debug mode

关于c# - ASP.Net MVC 5 子目录捆绑问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22612157/

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