标签:
using System; using System.Web; using System.Web.Optimization; namespace AutoBundleWeb { public static class ScriptsBundle2 { public static IHtmlString Bundle2(params string[] paths) { string path = RegisterBundles(paths); return Scripts.RenderFormat(Scripts.DefaultTagFormat, path); } private static string RegisterBundles(params string[] paths) { var key = Math.Abs(string.Join(null, paths).GetHashCode()); string virtualPath = string.Format("~/bundles/" + key); var bundle = BundleTable.Bundles.GetBundleFor(virtualPath); if (bundle == null) { var scriptBundle = new ScriptBundle(virtualPath); scriptBundle.Include(paths); BundleTable.Bundles.Add(scriptBundle); } return virtualPath; } } }
@ScriptsBundle2.Bundle2("~/Scripts/bootstrap.js", "~/Scripts/respond.js")
标签:
原文地址:http://www.cnblogs.com/chinaniit/p/4731617.html