Sunday, March 27, 2016

404 error for .woff font file in asp.net

When you use font awesome in asp.net, you get the 404 file not found error for the font files.

Error:

Failed to load resource: the server responded with a status of 404 (Not Found).
http://localhost/web-led/font-awesome/fonts/fontawesome-webfont.woff2?v=4.3.0



Fix:
This can be fixed by adding the mime type in the web config, under the system.webServer section

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


As mentioned by Deepak in the comments, if you have access to the iis you can easily set it from IIS itself. 

2 comments: