Skip to content

Instantly share code, notes, and snippets.

@kdarty
Created September 23, 2016 12:09
Show Gist options
  • Save kdarty/a984201e64d06c916085a07ba3c6930f to your computer and use it in GitHub Desktop.
Save kdarty/a984201e64d06c916085a07ba3c6930f to your computer and use it in GitHub Desktop.
Define Web Font Mime Types within the Web.config of an ASP.NET Project to ensure that the Web Server properly handles serving up your Fonts.
<system.webServer>
<staticContent>
<!-- Remove any potential Web Server Settings for Web Fonts to be used -->
<remove fileExtension=".eot" />
<remove fileExtension=".otf" />
<remove fileExtension=".ttf" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<!-- Define Web Font Mime Types that will be used -->
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="application/font-sfnt" />
<mimeMap fileExtension=".ttf" mimeType="application/font-sfnt" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
<!-- Define SVG Mime Type (could be used for Images or Fonts) -->
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
@Loque-
Copy link

Loque- commented Oct 26, 2020

application/font-sfnt is not the right mimetype for ttf or otf - not sure why you would use it?

Try application/x-font-ttf or application/x-font-truetype for ttf and application/x-font-opentype for otf

Edit: I can see some history on it here: https://stackoverflow.com/a/20723357 hope this helps others! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment