ASP.NET MVC 4 ScriptBundle返回空 [英] ASP.NET MVC 4 ScriptBundle returns empty
问题描述
具体来说,我想在MVC 4创建ScriptBundle与已经缩小的脚本,并返回该同捆的项目是否在调试或没有。
Specifically, I am trying to create a ScriptBundle in MVC 4 with already minified scripts, and return this same Bundle whether the project is in Debug or not.
我的web项目引用MVC Telerik的电网的NuGet包。在那个包,Telerik的只提供了缩小的JS文件。捆绑code如下。
My web project references the MVC Telerik Grid NuGet package. In that package, Telerik only provides the minified JS files. Bundling code is below.
// telerik scripts
bundles.Add(new ScriptBundle("~/scripts/bundles/telerik").Include(
"~/Scripts/2012.1.214/telerik.common.min.js",
"~/Scripts/2012.1.214/telerik.textbox.min.js",
"~/Scripts/2012.1.214/telerik.calendar.min.js",
"~/Scripts/2012.1.214/telerik.datepicker.min.js",
"~/Scripts/2012.1.214/telerik.grid.min.js",
"~/Scripts/2012.1.214/telerik.grid.filtering.min.js"));
其他ScriptBundles运行良好,但是当我的项目试图引用这个包,请求显示为:?脚本/包/ Telerik的V =
返回什么
如果我设置 BundleTable.EnableOptimizations = TRUE
,则它返回ScriptBundle和引用特定的版本,但是这个解决方案是不可接受的。
If I set BundleTable.EnableOptimizations = true
, then it DOES return the ScriptBundle and references a specific version, however this solution is unacceptable.
我不想强行将 BundleTable.EnableOptimizations = TRUE
,因为我希望所有其他包在适当的时候返回非精缩版。
I do not want to forcibly set BundleTable.EnableOptimizations = true
, since I want all other Bundles to return the non-minified versions when appropriate.
任何人都有类似的经历,如果是这样,究竟是什么解决方案?
Anyone have a similar experience and if so, what was the solution?
推荐答案
我觉得你有同样的问题,请看看这个链接:不包括mvc4打捆.min文件
I think you have the same problem, please look at this link: mvc4 bundler not including .min files
要么重新命名为.min.js或.js文件做这样的事情:
Either rename .min.js to .js or do something like:
public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
{
if (ignoreList == null)
throw new ArgumentNullException("ignoreList");
ignoreList.Clear();
ignoreList.Ignore("*.intellisense.js");
ignoreList.Ignore("*-vsdoc.js");
ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
//ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
}
这篇关于ASP.NET MVC 4 ScriptBundle返回空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!