【发布时间】:2015-09-12 16:57:38
【问题描述】:
我正在尝试使用 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 创建多个内容包?
【问题讨论】:
标签: c# asp.net asp.net-mvc-4 cdn bundles