Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
When I run my MCV 5 app locally, these Glyphicons work fine. However, after I publish my site to the web server, these glyphicons don't show on the published site.

Below is in my bundleConfig.cs:

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/font-awesome.css",
"~/fonts/glyphicons-*",
"~/Content/site.css"));

BundleTable.EnableOptimizations = false;

Below is the default font setting of Bootstrap.css version 3.3.7:

@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');
}

Does anyone know how I can fix this? The fonts folder is at the root level. Note: I am not using the "min" .css or .js version.


Thank you.

What I have tried:

I have tried moving the fonts folder path to the "Content" folder but that didn't solve the problem. Suggestions please? Thank you.
Posted
Updated 21-Dec-16 9:32am

Firstly, remove the "~/fonts/glyphicons-*" line from your bundle config. This will try to render the raw bytes of the font files as CSS, which will not work.

The most likely problem is that IIS doesn't know the MIME type for the font files. For security reasons, IIS will not serve any file where it doesn't know the MIME type.

To fix it, add a web.config file to your fonts folder with the following content:
XML
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension="eot" mimeType="application/vnd.ms-fontobject" />
            <mimeMap fileExtension="otf" mimeType="application/x-font-opentype" />
            <mimeMap fileExtension="svg" mimeType="image/svg+xml" />
            <mimeMap fileExtension="ttf" mimeType="application/x-font-truetype" />
            <mimeMap fileExtension="woff" mimeType="application/font-woff" />
            <mimeMap fileExtension="woff2" mimeType="application/font-woff2" />
        </staticContent>
    </system.webServer>
</configuration>
 
Share this answer
 
Comments
blumonde - 21-Dec-16 9:04am    
@Richard, Thank you for the suggestion. I am a bit confused when you say 'add a web.config file to your fonts folder'. I have no idea what do you mean by that; I do have a web.config file at the root of my project. Is that the file you suggested I add those mimeMap lines to? Thank you.
Richard Deeming 21-Dec-16 9:07am    
Create a new file called "web.config" in the fonts folder, and replace the content with the example I posted.
blumonde - 21-Dec-16 9:15am    
I tried adding web.config to the font folder too yesterday but it did nothing. Thank you.
blumonde - 21-Dec-16 9:05am    
I used Chrome browser debugger and found 3 errors regarding the glyphicon fonts. The errors have status of 403 (forbidden).

Why are they forbidden to load on the web server do you know? How do I fix this?

Thank you.
Richard Deeming 21-Dec-16 9:07am    
The 403 response is because IIS doesn't know about the MIME type of the font files.
In case anyone else has the same problem, the system admin fixed it by adding file types to the IIS manager.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900