How Can I have IIS properly serve .webmanifest files on my web site?

IisWeb Manifest

Iis Problem Overview


The Favicon Generator assembles a package for webmasters to use in order to have icons available for many different devices. The page comes with a file called site.manifest which is linked to via the following tag in the web page's document <head>:

<link rel="manifest" href="site.webmanifest">

According to Mozilla: "The web app manifest provides information about an application (such as name, author, icon, and description) in a JSON text file. The purpose of the manifest is to install web applications to the homescreen of a device, providing users with quicker access and a richer experience."

Unfortunately if you are using Microsoft's Internet Information Services (IIS), you'll get a 404.3 error if you try and access the site.webmanifest file.

The exact error message is as follows: "The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map."

How can I properly serve site.webmanifest files in IIS?

Iis Solutions


Solution 1 - Iis

By default, IIS does not serve any files that does not have a MIME map associated with it in its (IIS) core settings.

To address this challenge, you will need to map the .webmanifest file extension to its appropriate MIME type.

To accomplish this, open IIS and follow the steps below;

  1. On the left hand side, select either your web site or the entire server in the "Connections" menu. If you select the server, your MIME mapping will apply to every web site on the server. If you select a web site, it will only apply to a single web site.

  2. Next, select "MIME Types" from the IIS menu:

MIME Types Menu Item

  1. Once there, click "add..." from the right hand menu.

  2. In the dialog box that opens specify .webmanifest in the file name extension box application/manifest+json in the MIME type box.

Add MIME Type dialog box

  1. Click "OK".

Congratulations; you've just defined the MIME type for .webmanifest on IIS.

Solution 2 - Iis

For Azure I added this as the web.config

<?xml version="1.0"?>
 
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".json" mimeType="application/json" />
            <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
        </staticContent>
    </system.webServer>
</configuration> 

Solution 3 - Iis

For those using ASP.NET Core (I am using 2.1) you can configure the MIME types that can be served in the application Startup.cs file as per the static files docs:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    FileExtensionContentTypeProvider provider = new FileExtensionContentTypeProvider();
    provider.Mappings[".webmanifest"] = "application/manifest+json";

    app.UseStaticFiles(new StaticFileOptions()
    {
        ContentTypeProvider = provider
    });

    app.UseMvc();
}

Solution 4 - Iis

Easier solution is to rename your manifest file to site.webmanifest.json and link as

 <link rel="manifest" href="site.webmanifest.json">

IIS should already have a MIME Type for .json files This is also helpful if deploying to Azure where its not so easy to change the IIS settings.

Solution 5 - Iis

Adding to @Ben's answer: if you have a SPA you should put StaticFileOptions code into the UseSpaStaticFiles() call:

FileExtensionContentTypeProvider provider = new FileExtensionContentTypeProvider();
provider.Mappings[".webmanifest"] = "application/manifest+json";

app.UseSpaStaticFiles(new StaticFileOptions()
{
    ContentTypeProvider = provider
});

Solution 6 - Iis

I found that the IIS server had ".json" listed in the Request Filtering feature saying it was not allowed.

enter image description here

Removing that allowed the file to be served.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDave LView Question on Stackoverflow
Solution 1 - IisDave LView Answer on Stackoverflow
Solution 2 - IisRichard HubleyView Answer on Stackoverflow
Solution 3 - IisBenView Answer on Stackoverflow
Solution 4 - IisPeter KerrView Answer on Stackoverflow
Solution 5 - IisCezar CrinteaView Answer on Stackoverflow
Solution 6 - IisGlen LittleView Answer on Stackoverflow