ASP.NET MVC Script bundle not rendered

試著忘記壹切 提交于 2019-12-21 04:06:08

问题


I've included the following line in the BundleConfig.cs file:

bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include(
  "~/Scripts/jquery.unobtrusive-ajax.min.js"));

However when I try to render it among other scripts, it's skipped.

Here is how I render the scripts:

@Scripts.Render(
    "~/bundles/jquery",
    "~/bundles/jqueryui",
    "~/bundles/jqueryajax",
    "~/bundles/jquerytree")

This is the output HTML, the jqueryajax bundle is omitted:

<script src="/Scripts/jquery-1.9.1.js"></script>
<script src="/Scripts/jquery-ui-1.10.2.js"></script>
<script src="/Scripts/jquery.jstree.js"></script>

回答1:


I believe ScriptBundle tries to minify the file when debug="false" instead of using the existing .min.js file. There is a setting in web.config to affect how this works (set usePreMinifiedFiles to true):

<core enableTracing="false" ...>
     <js defaultMinifier="EdwardsJsMinifier" usePreMinifiedFiles="true">


来源:https://stackoverflow.com/questions/16292493/asp-net-mvc-script-bundle-not-rendered

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