asp.net-mvc-4 – 在一个StyleBundle中使用多个CDN链接

我有以下代码
bundles.UseCdn = true;

var fontPath = "http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600";

var commonCss = new StyleBundle("~/css/common").Include(
    "~/Content/less/myless.less","~/Content/css/opensans.css",// local copy of the font path above
    "~/Content/less/mylessoverrides.less","~/Content/css/font-awesome.css");

commonCss.Transforms.Add(new CssMinify());
bundles.Add(commonCss);

上面的代码工作正常.但是,我想从上面的CDN链接加载opensans.css.我也希望把它作为一个包,并保持捆绑的顺序完好无损.以下代码会抛出错误

var commonCss = new StyleBundle("~/css/common").Include(
    "~/Content/less/myless.less","http://fonts.googleapis.com/css?family=Open+Sans:400italic,600","~/Content/less/mylessoverrides.less","~/Content/css/font-awesome.css");

The URL 'http://fonts.googleapis.com/css?family=Open+Sans:400italic,600'
is not valid. Only application relative URLs (~/url) are allowed.

一个解决方法是将它分成三个捆绑包,但这将违反捆绑的整个目的:

var commonCss1 = new StyleBundle("~/css/common1").Include(
    "~/Content/less/myless.less");

var commonCss2 = new StyleBundle("~/css/common2",fontPath).Include(
    "~/Content/css/opensans.css");

var commonCss3 = new StyleBundle("~/css/common3").Include(
    "~/Content/less/mylessoverrides.less","~/Content/css/font-awesome.css");

最终的解决办法是做一些事情:

var commonCss = new StyleBundle("~/css/common").Include(
    "~/Content/less/myless.less",new { fontPath,"~/Content/css/opensans.css" },"~/Content/css/font-awesome.css");

有没有人设法解决这个问题,还是设法扩展允许这种行为的框架?

解决方法

你可以使用
@import url("http://fonts.googleapis.com/css?family=Open+Sans:400italic,600");

你想要在本地的css文件

相关文章

项目要求通过网站上传大文件,比如视频文件,通过摸索实现了文件分片来上传,然后后台进行合并。 使用了...
安装新版本的Nginx(vim /etc/yum.repos.d/nginx.repo) [nginx-stable] name=nginx stable repo baseu...
什么是 SignalR ASP.NET Core ASP.NET Core SignalR 是一种开放源代码库,可简化将实时 web 功...
在Windows下使用Docker,我们选择Docker Desktop这个软件,非常方便。 ## Docker Desktop介绍及安装 Do...
项目开始设计的是运行在windows下,所以一开始采用的是windows服务模式来获取多媒体文件信息,后来要求...
银河麒麟高级服务器操作系统V10是针对企业级关键业务,适应虚拟化、云计算、大数据、工业互联网时代对主...