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")
まだ localhost アイコンは正常に表示されますが、コードをリリース サーバーにプッシュすると、アイコンではなく四角形しか表示されず、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
ありがとうございました。