【问题标题】:MVC Bundling: IncludeDirectory not working as expectedMVC 捆绑:IncludeDirectory 未按预期工作
【发布时间】:2015-04-04 04:52:53
【问题描述】:

我正在尝试将脚本包添加到我的 MVC 站点。起初我明确命名了这些文件:

var scripts = new ScriptBundle("~/scripts/bundle")
    .Include("~/scripts/jquery-2.1.3.min.js")
    .Include("~/scripts/jquery.validate-1.13.0.min.js")
    .Include("~/scripts/jquery.validate.unobtrusive.min.js");

bundles.Add(scripts);

这按预期工作。但是,我后来决定只包含整个目录会更容易:

var scripts = new ScriptBundle("~/scripts/bundle")
    .IncludeDirectory("~/scripts", "*.js", true);

bundles.Add(scripts);

第二种方法在调用@Scripts.Render()时没有输出任何东西,所以我只能假设IncludeDirectory方法没有找到任何东西。我做错了什么?

编辑:我也尝试过通配符语法

var scripts = new ScriptBundle("~/scripts/bundle")
    .Include("~/scripts/*.js");

这也无法渲染任何东西

【问题讨论】:

标签: c# asp.net-mvc-4 bundle bundling-and-minification


【解决方案1】:

试试:

var scripts = new ScriptBundle("~/scripts/bundle")
    .Include("~/scripts/*.js")

【讨论】:

  • 感谢您的建议,但不幸的是,这也不起作用。虽然它可能会帮助其他人
猜你喜欢
  • 2023-04-08
  • 2014-07-02
  • 2010-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-19
  • 2012-08-17
  • 1970-01-01
相关资源
最近更新 更多