Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add MIME mapping in web.config for IIS Express

I need to add a new MIME mapping for .woff file extensions to IIS Express.

If I add the following snippet to the "applicationhost.config" of IIS Express it works fine:

<staticContent lockAttributes="isDocFooterFileName">     <mimeMap fileExtension=".woff" mimeType="font/x-woff" />     ... 

But I would actually like to do add it to my "web.config" so that not every developer would need to change their "applicationhost.config" locally.

So I removed it again from the "applicationhost.config" file and added the following snippet to the project's "web.config":

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

Unfortunately it doesn't seem to work that way because when I try to access a .woff file I end up with a HTTP 404.3 error.

What am I doing wrong?

like image 272
Martin Buberl Avatar asked Jan 26 '12 16:01

Martin Buberl


People also ask

How do you add a MIME map?

In the Connections pane, go to the site, application, or directory for which you want to add a MIME type. In the Home pane, double-click MIME Types. In the MIME Types pane, click Add... in the Actions pane. In the Add MIME Type dialog box, add the file name extension and MIME type, and then click OK.

Does IIS Express use web config?

Yes, IIS Express uses the same applicationhost. config and web. config files supported by IIS.


1 Answers

Putting it in the "web.config" works fine. The problem was that I got the MIME type wrong. Instead of font/x-woff or font/x-font-woff it must be application/font-woff:

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

See also this answer regarding the MIME type: https://stackoverflow.com/a/5142316/135441

Update 4/10/2013

Spec is now a recommendation and the MIME type is officially: application/font-woff

like image 182
Martin Buberl Avatar answered Sep 22 '22 23:09

Martin Buberl