Azure Web App - Missing MIME types

If you are seeing "404 Not Found" for .woff, .woff2 or for .json files even if they exist on your azure web app, this is the post for you.

commit 4c3e758 · authored · amended · 2 min read

Azure Web App - Missing MIME types

When you deploy an app to Azure app service (Web App), you may notice that the custom font isn’t showing up or some specific files is getting 404 even if they exist on the right place.

This is because of the missing Mime type definitions.

Mime Types

Its definition is,

A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) is a standard that indicates the nature and format of a document, file, or assortment of bytes.

And if you want to know why it is causing the 404, read this article.

Missing Mime Types

Font Files

<mimeMap fileExtension="woff" mimeType="application/font-woff" />
<mimeMap fileExtension="woff2" mimeType="application/font-woff" />

Json

<mimeMap fileExtension=".json" mimeType="application/json" />

SVG

<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />

More

<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
<mimeMap fileExtension=".webp" mimeType="image/webp" /> <!-- Not all browser supports webp />

Sample web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension="woff"/>
<mimeMap fileExtension="woff" mimeType="application/font-woff" />
<remove fileExtension="woff2"/>
<mimeMap fileExtension="woff2" mimeType="application/font-woff" />
<remove fileExtension=".json"/>
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>

Curious about remove fileExtension ? MimeMap collection inherits but it won’t allow duplicate entries. If a duplicate mimeMap definition is added, it will result,

IIS7 Error: cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’

So for the safe side, we are removing the global definition for that extension before changing it.

local graph · open full graph

"Azure Web App - Missing MIME types" is connected to the topics Microsoft Azure, Web.config and related to 6 other entries. Cost Optimization: Auto Shutdown and Startup of Tagged VMs with Azure Automation Cost Optimization: Auto Shu… Azure - Configuring End-to-End SSL for IIS Website by using Application Gateway Azure - Configuring End-to-… C# - Get Web.Config Connection String in a Class Library C# - Get Web.Config Connect… IIS - Disable CORS IIS - Disable CORS Azure Web App - Web Deploy to a Sub-folder Azure Web App - Web Deploy … Hunting security bugs in an old web application Hunting security bugs in an… Microsoft Azure #azure Web.config #web-config Azure Web App - Missing MIME types

comments

loading discussion…