ASP.Net MVC 5 sub-directory bundling issues

廉价感情. 提交于 2019-12-01 00:00:37

问题


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",
                .....

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 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>

The path to file2.js is wrong. It omits the subdir1 part of the path. Am I missing something here?


回答1:


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.

Web Optimization path issue while in debug mode



来源:https://stackoverflow.com/questions/22612157/asp-net-mvc-5-sub-directory-bundling-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!