How to remove error about glyphicons-halflings-regular.woff2 not found

106,457

Solution 1

This problem happens because IIS does not know about woff and woff2 file mime types.

Solution 1:

Add these lines in your web.config project:

 <system.webServer>
  ...
  </modules>
    <staticContent>
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
    </staticContent>

Solution 2:

On IIS project page:

Step 1: Go to your project IIS home page and double click on MIME Types button:

Step 1

Step 2: Click on Add button from Actions menu: Step 2

Step 3: In the middle of the screen appears a window and in this window you need to add the two lines from solution 1: Step 3

Solution 2

In my case, I've just downloaded the missing file directly from here: https://gitlab.com/mailman/mailman-website/raw/a97d6b4c5b29594004e3855f1ab1222449d0c211/content/fonts/glyphicons-halflings-regular.woff2

Solution 3

Add this one to your html if you only have access to the html:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">

Solution 4

For me, the problem was twofold: First, the version of IIS I was dealing with didn't know about the .woff2 MIME type, only about .woff. I fixed that using IIS Manager at the server level, not at the web app level, so the setting wouldn't get overridden with each new app deployment. (Under IIS Manager, I went to MIME types, and added the missing .woff2, then updated .woff.)

Second, and more importantly, I was bundling bootstrap.css along with some other files as "~/bundles/css/site". Meanwhile, my font files were in "~/fonts". bootstrap.css looks for the glyphicon fonts in "../fonts", which translated to "~/bundles/fonts" -- wrong path.

In other words, my bundle path was one directory too deep. I renamed it to "~/bundles/siteCss", and updated all the references to it that I found in my project. Now bootstrap looked in "~/fonts" for the glyphicon files, which worked. Problem solved.

Before I fixed the second problem above, none of the glyphicon font files were loading. The symptom was that all instances of glyphicon glyphs in the project just showed an empty box. However, this symptom only occurred in the deployed versions of the web app, not on my dev machine. I'm still not sure why that was the case.

Solution 5

I tried all the suggestions above, but my actual issue was that my application was looking for the /font folder and its contents (.woff etc) in app/fonts, but my /fonts folder was on the same level as /app. I moved /fonts under /app, and it works fine now. I hope this helps someone else roaming the web for an answer.

Share:
106,457
Andrus
Author by

Andrus

Updated on July 08, 2022

Comments

  • Andrus
    Andrus almost 2 years

    ASP.NET MVC4 Bootstrap 3 application is running from Microsoft Visual Studio Express 2013 for Web IDE.

    Chrome console shows always error

    http://localhost:52216/admin/fonts/glyphicons-halflings-regular.woff2
    Failed to load resource: the server responded with a status of 404 (Not Found)
    

    This file exists in the fonts directory in the Solution Explorer. Build action is set to "Content" and Copy to Output directory is "Do not copy like in other font files". Bootstrap 3 is added to the solution using NuGet. How to fix this so that this error does not occur? Application shows Glyphicon and FontAwesome icons properly. This error always occurs at application startup.

  • Bpainter
    Bpainter over 8 years
    This solved it for me, but why? I would appreciate an explanation as to why the solution works more than just a mindless copy/paste of provided code.
  • Camille Sévigny
    Camille Sévigny over 8 years
    @Bpainter The first line in this answer tells you why. The mime types are not associated to a type so they fail to load by the browser. Why won't a browser load an un-associated mime type file? I think that's a separate question which I do not know the answer to.
  • Grungondola
    Grungondola over 8 years
    @CamilleSévigny I believe the answer to your question is that IIS only makes available valid file types, so since it does not recognize the .woff and .woff2 extensions, it responds to requests for these files with 404 - not found.
  • Bpainter
    Bpainter over 8 years
    @CamilleSévigny Thanks, when I made that comment, the first line was not there. It was edited in after the fact. Without your comment though I never would have seen it.
  • CyprUS
    CyprUS almost 8 years
    solved it for me . Thanks. I downloaded the files, and saved the fonts folder under my project directory. CSS files in "css" folder, fonts in "fonts" folder
  • g_brahimaj
    g_brahimaj over 7 years
    In my case the problem was the CssRewriteUrlTransform that I used in the Bundle of bootstrap and Font-Awesome. If you preserve their normal folder structure, there is no need to use this option.
  • Irf
    Irf almost 7 years
    At times solutions are pretty simple, and we are unaware of : ) Thnx for the solution, I missed this in my fonts folder in my MVC5 app
  • Sacha K
    Sacha K about 6 years
    The current standard mime types are application/font-woff and font/woff2, see w3.org/TR/WOFF/#appendix-b and w3.org/TR/WOFF2/#IMT
  • BUDDHIKA
    BUDDHIKA almost 5 years
    Thanks, This solution worked for me. But, adding <staticContent> tag in the web.config as the per this - stackoverflow.com/questions/46508793/… - did not work for me.