ASP.Net MVC 5子目录绑定问题 [英] ASP.Net MVC 5 sub-directory bundling issues
问题描述
我看到在我的ASP.Net MVC项目5捆绑一个怪异的行为。我的项目工作就好了,当我明确地声明,我BundleConfig.cs文件中的所有文件内容如下:
I am seeing a weird behavior with bundling in my ASP.Net MVC 5 project. My project works just fine when I explicitly declare all the files in my BundleConfig.cs file as follows:
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
)是不完整的。这是我所看到的:
However, if I switch to use IncludeDirectory
instead, the script paths during development (BundleTable.EnableOptimizations = false
) are not complete. This is what I see:
bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/app/app.js",
"~/app/config.js")
.IncludeDirectory("~/app/dir1", "*.js", true)
Chrome会显示我404当它试图让 file2.js
。捆绑系统添加以下到我的布局页:
Chrome shows me a 404 when it is trying to get file2.js
. The bundling system adds the following to my layout page:
<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
部分。我失去了一些东西在这里?
The path to file2.js
is wrong. It omits the subdir1
part of the path. Am I missing something here?
推荐答案
这是一个已知的问题瓦特/ 1.1.1版本。升级包(或降级到1.1.0),它应该解决您的问题。
This is a known issue w/ version 1.1.1. Upgrade the package (or downgrade to 1.1.0) and it should fix your problem.
这篇关于ASP.Net MVC 5子目录绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!