我正在处理 ASP.NET MVC 4 中的一个项目,我执行了以下步骤:
从http://blog.getbootstrap.com/2013/12/05/bootstrap-3-0-3-released/下载 twitter 引导程序
将字体文件的构建操作设置为内容(文件位于 ~/Content/font 文件夹中)
glyphicons-halflings-regular.eot glyphicons-halflings-regular.svg glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff
添加到 RouteConfig.cs
routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "Content" });
向 Web.config 添加了以下元素
<?xml version="1.0" encoding="UTF-8"?> <system.webServer> <staticContent> <remove fileExtension=".eot" /> <remove fileExtension=".ttf" /> <remove fileExtension=".otf"/> <remove fileExtension=".woff"/> <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" /> <mimeMap fileExtension=".ttf" mimeType="font/ttf" /> <mimeMap fileExtension=".otf" mimeType="font/otf" /> <mimeMap fileExtension=".woff" mimeType="font/x-woff" /> </staticContent> </system.webServer>
在 BundleConfig.cs 中包含以下代码
bundles.Add(new StyleBundle("~/bundles/maincss") .Include("~/Content/bootstrap/bootstrap.css") .Include("~/Content/bootstrap/bootstrap-theme.css") .Include("~/Content/hbl-full.css"));
还尝试了以下代码
IItemTransform cssFixer = new CssRewriteUrlTransform(); bundles.Add(new StyleBundle("~/bundles/maincss") .Include("~/Content/bootstrap/bootstrap.css", cssFixer) .Include("~/Content/bootstrap/bootstrap-theme.css", cssFixer) .Include("~/Content/hbl-full.css", cssFixer));
在主 Layout.cshtml 中调用
@Styles.Render("~/bundles/maincss")
仍然在本地主机中正常显示图标,但是当我推送代码以发布服务器时,我只能看到方形而不是图标,并且在 Chrome 的控制台选项卡中我得到
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.woff 404(未找到)测试:1
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.ttf 404(未找到)测试:1
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.svg 404(未找到)测试:1
谢谢你。