Bundling scripts are not getting rendered

﹥>﹥吖頭↗ 提交于 2019-11-27 16:07:44

You can't give your bundle a name that is also the name of an existing directory. Rename the bundle or add a /js to make it work correctly:

bundles.Add(new ScriptBundle("~/Scripts/js").IncludeDirectory("~/Scripts", "*.js").IncludeDirectory("~/Scripts/kendoui", "*.js"));

and

@Scripts.Render("~/Scripts/js")

Any other name that doesn't exist would work as well, e.g.

 bundles.Add(new ScriptBundle("~/ScriptMonkey").IncludeDirectory("~/Scripts", "*.js").IncludeDirectory("~/Scripts/kendoui", "*.js"));

...assuming you don't have /ScriptMonkey directory.

Have you tried using non existing directory in Bundle's virtual path? Like

...new ScriptBundle("~/bundle/Scripts")...
user007

The accepted answer did not work for me. I use MVC 4.0 on Visual Studio 2010 SP1. I had a js file named "jquery-ui.min.js" file and was not getting loaded. My Bundle.config code was:

bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(                        
                            "~/Scripts/jquery-ui.min.js"));

I renamed the file to jquery-ui.js and updated my code as

bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(                        
                        "~/Scripts/jquery-ui.js"));

I got this information from here.

The bundle module logic that decides whether or not to handle a request, will not takeover requests to existing files or directories. So that's why your bundle requests don't work when they live at the same virtual path as an existing directory (or file).

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