WOFF files return 404 (Not Found) in Azure Web Sites


I've just starting using Azure Web Sites to publish certain sites.  I've also recently braved using web fonts from certain providers.

After publishing my site today, I noticed when I ran it, that the WOFF font type was returning a 404 error:
WOFF file 404 on Azure Web Site

After treble checking my settings in Visual Studio 2013, the file was definitely there and not excluded from the project:
WOFF files in VS2013 project

MIME Recognition

It turns out that the problem is actually caused by Azure, not by anything we've done wrong!  Azure doesn't actually have a MIME type configured for WOFF files, so simply returns 404 (surely there would be a better HTTP Error number for this?!?).

The fix is really simple.  Head to the web.config file and add a <staticContent> into the <configuration> element:

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

Once that's in, Azure correctly delivers our WOFF files:Once that's in, Azure correctly delivers our WOFF files:
WOFF file served by Azure


c# · ‎font · ‎woff · ‎woff2 · ‎mime · ‎404 · ‎notfound · ‎azure

Última atualização: 14/11/2017 às 16:18


  • Buscar