Surendra Sharma

Surendra Sharma

Search This Blog

Saturday, May 16, 2015

How to fix 404 error for fonts in ASP.NET

My tester informed me that we are getting 404 for woff font file. I checked the presence of woff file in fonts folder. I checked the path of font file. Both these checks are positive and everything was seems to be correct. We were not getting the 404 error for any other font file except woff file. Then I googled it and come to know that people are already facing the same error for woff font file.

This is the problem of MIME type. So there are two ways to solve it.

·         IIS
·         Entry in ASP.NET project’s web.config file

Through IIS
          You to make MIME entry in IIS as below for this font

·         Run IIS Server Manager, Open Mime Types and add following
o    File name extension: .woff
o    MIME type: application/x-font-woff

Through web.config file

You can also add the entry of MIME types in the web config as follows

      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />

I prefer the second option of web.config file as this file is a part of our project and we can change it at any time. But it’s very difficult to get the access of IIS on production or client environment.

Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment