我正在尝试使用 ASP.NET MVC 4 添加一些支持 CDN 的捆绑包。目的是由托管在同一数据中心的许多其他站点在本地共享内容
第一次尝试是:
bundles.Add(new ScriptBundle("~/bundles/jquery", "http://mysite/Content/js/").Include(
"http://mycdnsite/Content/js/jquery.unobtrusive-ajax.min.js",
"http://mycdnsite/Content/js/jquery-migrate-1.2.1.js",
"http://mycdnsite/Content/js/jquery-{version}.js"));
不幸的是,这是不可能的,因为 virtualPaths 必须是相对的(只允许应用程序的相对 URL (~/url))
然后我试过这个:
bundles.Add(new ScriptBundle("~/bundles/jquery", "http://mycdnsite/Content/js/").Include(
"~/jquery.unobtrusive-ajax.min.js",
"~/jquery-migrate-1.2.1.js",
"~/jquery-{version}.js"));
但它没有奏效,甚至启用了 CDN:
BundleTable.EnableOptimizations = true;
bundles.UseCdn = true;
是否可以使用 CDN 创建多个内容包?