环境为vs2013需要将 工具-库程序包管理-nuget管理,更新 microsoft asp.net web optimization1.1.3,系统默认好像是1.0.0,如果不更新,不能继承IItemTransform,会提示命名空间不存在,更新即可。
更改bundleconfig.cs
public class CssRewriteUrlTransformWrapper : IItemTransform { public string Process(string includedVirtualPath, string input) { return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input); } } bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap/css/bootstrap.css" ).Include("~/Content/plugins/magnific-popup/magnific-popup.css" ).Include("~/Content/plugins/owl-carousel/owl.carousel.css" ).Include("~/Content/css/style.css" ).Include("~/Content/css/custom.css" ).Include("~/Content/css/skins/red.css" ).Include("~/Content/css/animations.css", new CssRewriteUrlTransformWrapper())); BundleTable.EnableOptimizations = false;