I`m working on a project in ASP.NET MVC 4 and I did following steps:
Downloaded twitter bootstrap from http://blog.getbootstrap.com/2013/12/05/bootstrap-3-0-3-released/
Set Build action on font files to Content (files are located in ~/Content/font folder)
glyphicons-halflings-regular.eot glyphicons-halflings-regular.svg glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff
Added to RouteConfig.cs
routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "Content" });
Added following elements to 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>
Included following code in BundleConfig.cs
bundles.Add(new StyleBundle("~/bundles/maincss") .Include("~/Content/bootstrap/bootstrap.css") .Include("~/Content/bootstrap/bootstrap-theme.css") .Include("~/Content/hbl-full.css"));
Also tried with following code
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));
Called in main Layout.cshtml
@Styles.Render("~/bundles/maincss")
Still in localhost icons are shown normally, but when I push code to release server, I can only see square instead of icon and in Chrome`s Console tab I get
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.woff 404 (Not Found) test:1
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.ttf 404 (Not Found) test:1
GET http://domain.apphb.com/fonts/glyphicons-halflings-regular.svg 404 (Not Found) test:1
Thank you.
I had the same problem. I got around it by using bootstrap's CDN.
I had the same issue. I don't really know why but if I remove the bootstrap.min.css file and set the CssRewriteUrlTransform on the bundle everything is working. I'm using bootstrap v3.1.1
EDIT: After some investigation the solution is defined here : CssRewriteUrlTransform is not being called So removing the bootstrap.min.css or referencing bootstrap.min.css instead of bootstrap.css will force the bundling/minification on your file and so it will call the CssRewriteUrlTransform.
I had this problem and I found it was happening due to the minification when building in release mode.
Rather than downloading the files manually from the bootstrap site and configuring bundling I use the nuget package which does it for me.
If you would like to do that take the following steps.
Run the following command to install Bootstrap:
This downloads all the bootrap files and includes the below pre-defined Bootstrap bundle config:
The above also includes comments describing how to render out the bundles.
I think the original 404 font error was due the fonts folder being at a different level to what is specified in the minified css.
If you prefer to keep your current solution the only way I could fix the 404 was to copy the font folder to the root of the web application.
To test it locally simply remove
debug="true"
from your web config to save deploying to AppHarbor.I had the same problem, using IIS 7.5 webserver.
The solution was to add .woff to the list of file name extensions with MIME type application/octet-stream on the webserver.
You could also achieve the same in web.config:
Here's how I solved it -- I'm using MVC5 and Bootstrap 3.1.1.
I have my files organized in the project like this:
Then I added another level to my virtual path in the bundle config
Previously I had used
~/Content/css
And in the view...
This worked but I still got a 404 on one of the fonts... so I added Giles' solution.
Copying the font folder to the root of the web app and changing the mime types in web.config to
fixed the issue for me. Please note that the .woff mimeType is different to the one in the question.