问题
I am using John Papa's SPA jump start App to create my own app and for every part of his tutorial I complete I keep running into the same problem.
In a new section of the tutorial I have to add another javaScript file and to this I use BundleConfig.cs. I copy and paste the .Include method and add the new JS file. But in firebug I can't see the script in the network tab.
using System;
using System.Web.Optimization;
namespace AgencyUpdate
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.IgnoreList.Clear();
AddDefaultIgnorePatterns(bundles.IgnoreList);
bundles.Add(
new ScriptBundle("~/scripts/modernizr")
.Include("~/scripts/modernizr-{version}.js"));
bundles.Add(
new ScriptBundle("~/scripts/vendor")
.Include("~/scripts/jquery-{version}.min.js")
.Include("~/scripts/bootstrap.min.js")
.Include("~/scripts/knockout-{version}.js")
.Include("~/scripts/sammy-{version}.js")
.Include("~/scripts/moment.min.js")
.Include("~/scripts/Q.js")
.Include("~/scripts/breeze.min.js")
.Include("~/scripts/toastr.js"));
bundles.Add(
new StyleBundle("~/Content/css")
.Include("~/Content/ie10mobile.css") // Must be first. IE10 mobile viewport fix
.Include("~/Content/bootstrap.min.css")
.Include("~/Content/bootstrap-responsive.min.css")
.Include("~/Content/font-awesome.min.css")
.Include("~/Content/toastr.css")
.Include("~/Content/styles.css")
);
}
public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
{
if (ignoreList == null)
{
throw new ArgumentNullException("ignoreList");
}
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);
}
}
}

Is this a bug or quirk of Visual Studio 20120?
回答1:
I had to create a new global.asax file for this to work. There was nothing wrong with my scriptbundles.
回答2:
I was trying to use jquery.loadmask.min.js and faced the same problem.
The solution is,
- Rename jquery.loadmask.min.js to jquery.loadmask-0.4.min.js
- Rename jquery.loadmask.js to jquerym.loadmask-0.4.js
Now in Script bundle add the files as following, bundles.Add(new ScriptBundle("~/bundles/jqueryloadmask"). Include("~/Scripts/jquery.loadmask-{version}.js"));
来源:https://stackoverflow.com/questions/17943362/new-scriptbundle-include-not-working-for-breeze-min-js