【发布时间】:2017-03-31 20:42:54
【问题描述】:
我已通过 StyleBundle 将引导 CSS 文件添加到我的 asp.net mvc 5 项目中。
(作为Cdn使用:https://www.asp.net/ajax/cdn#Bootstrap_Releases_on_the_CDN_14)
var bootstrapCssCdnPath = "http://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css";
var bootstrapCssBundle = new StyleBundle("~/bundles/css/bootstrap", bootstrapCssCdnPath).Include("~/Content/bootstrap.css");
//bootstrapCssBundle.CdnFallbackExpression // ?
bundles.Add(bootstrapCssBundle);
var bootstrapThemeCssCdnPath = "http://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap-theme.min.css";
var bootstrapThemeCssBundle = new StyleBundle("~/bundles/css/bootstraptheme", bootstrapThemeCssCdnPath).Include("~/Content/bootstrap-theme.css");
//bootstrapCssBundle.CdnFallbackExpression // ?
bundles.Add(bootstrapThemeCssBundle);
但是有一个问题:当我添加一个不正确的 URL 作为 CDN(例如添加 'ahttp' 而不是 'http')时,我的自定义“后备”css 文件没有被使用,而是显示 'ahttp://'我的 html 源代码。 当我在 Debug 或 Release 上运行我的网站时也是如此。
- 为什么我的后备没有被使用?
- StyleBundle 的 CdnFallbackExpression 是什么? (特别是对于 bootstrap.css 和 bootstrap-theme.css)
- .Include 应该是 .min.css 文件还是自动搜索 .min。版本优先?
- 有没有办法 .Include 多个 css 文件,使用带有后备的 Cdn,这样我就不必每次使用 Cdn 的每个 css 文件都创建一个新的 StyleBundle?
【问题讨论】:
标签: css asp.net-mvc twitter-bootstrap cdn