【发布时间】:2017-04-09 05:49:15
【问题描述】:
当我在虚拟路径下发布网站时,我遇到了 glyphicons-font 的问题。我得到了所有引导程序字体的 404 响应代码。正在此文件夹下查看字体:
/bower_components/bootstrap/dist/fonts/
但是当站点部署时它们实际上在这个文件夹下:
XXX/bower_components/bootstrap/dist/fonts/
我正在像这样注册我的 BundleConfig.cs:
bundles.Add(new StyleBundle("~/bundles/bowercss")
// bower:css
.Include("~/bower_components/bootstrap/dist/css/bootstrap.min.css", new CssRewriteUrlTransform())
.Include("~/bower_components/angular-ui-select/dist/select.min.css", new CssRewriteUrlTransform())
.Include("~/bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css", new CssRewriteUrlTransform())
.Include("~/bower_components/angular-ui-switch/angular-ui-switch.min.css", new CssRewriteUrlTransform())
.Include("~/bower_components/angular-xeditable/dist/css/xeditable.min.css", new CssRewriteUrlTransform())
// endbower
);
在我的 Web.config 上,我添加了对字体的支持:
<staticContent>
<!-- Add support to .woof2 files -->
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".svg" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
2016 年 12 月 12 日更新:
我已经尝试了 Aravind 提出的所有解决方案,但没有任何运气。 我什至将所有字体复制到根文件夹并覆盖自定义 css 中的字体系列以指向新文件,但它也不起作用:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
当站点部署在虚拟路径下时,如何正确下载字体?
【问题讨论】:
标签: c# asp.net-mvc gruntjs glyphicons