0

I'm in a .NET shop; Octopus and TeamCity are used for deploying to our testing and production environments. I added some .WOFF2 fonts to the /_css/fonts folder, and I'm referencing them as follows:

@font-face {
    font-family: Roboto;
    src: url(/_css/fonts/Roboto-Bold-webfont.eot);
    src: url(/_css/fonts/Roboto-Bold-webfont.woff2) format('woff2'), url(/_css/fonts/roboto-bold-webfont.woff), <!-- other fallback fonts -->

The .WOFF2 fonts appear on localhost, but somehow they are being omitted from the build output. What's weird is there is a reference to a .WOFF2 of FontAwesome that is successfully being output. I've checked the properties of the fonts in Visual Studio, and all the new (non-outputting) fonts are set to Copy Always to output directory. Despite all our efforts, we keep getting 404 errors for those fonts.

TIA for any help you can provide!

Nosnetrom
  • 138
  • 6
  • Are you hosting your application on IIS? If yes, this might be configuration problem. By default IIS is not accepting woff2 mime type. Check this: https://stackoverflow.com/a/28955302/7225096 – Peska Jul 03 '18 at 18:54
  • OK, I must have been using an old MIME type; I had it as `application/font-woff2`. I'll make that change and see how it goes. – Nosnetrom Jul 05 '18 at 13:37
  • Can you publish (release build) somewhere locally and check the files were included in the build? Or double check the files have actually been copied to the web server. – Kye Aug 14 '18 at 10:32

2 Answers2

0

You can add a MIME type inside the IIS Manager.

  1. Open the "MIME types" in your server Home page (or Home page of your specific
  2. Add ".woff2" with MIME type "font/woff2".

enter image description here

In my case it works with IIS 7.5.

Ali
  • 2,702
  • 3
  • 32
  • 54
0

You need to add IIS a MIME-TYPE for woff2. You can configure it in web.config

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

And you can also do this through IIS manager.

  1. Open the MIME Types
  2. Add .woff2 with MIME type as application/x-font-woff as well.
duyplus
  • 1
  • 1
  • 3