我在ASP上做一个项目.NET MVC 4和我执行了以下步骤:
从http://blog.getbootstrap.com/2013/12/05/bootstrap-3-0-3-released/下载twitter bootstrap
-
将字体文件的生成操作设置为Content(文件位于~/Content/font文件夹中)
glyphicons-halflings-regular.eot glyphicons-halflings-regular.svg glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff
-
添加到RouteConfig.反恐精英
routes.IgnoreRoute("{Folder}/{*pathInfo}",new{Folder="Content"});
-
在Web中添加了以下元素.配置
<?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"));
还try 了以下代码
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));
-
在Main Layout.cshtml中调用
@风格.渲染("~/bundles/maincss")
在localhost中,图标仍然正常显示,但当我按下代码来释放服务器时,我只能看到正方形而不是图标,在Chrome的控制台选项卡中,我可以看到
获取http://domain.apphb.com/fonts/glyphicons-halflings-regular.woff 404(未找到)测试:1
获取http://domain.apphb.com/fonts/glyphicons-halflings-regular.ttf 404(未找到)测试:1
获取http://domain.apphb.com/fonts/glyphicons-halflings-regular.svg 404(未找到)测试:1
非常感谢.