Alex Chaney
Alex Chaney

Reputation: 41

Manifest JSON 404 not found for PWA?

I have a web application built in Visual Studio (C#) and I'm trying to turn it into/make it a PWA (progressive web app). I have created a manifest json file :

{
  {
    "dir": "ltr",
    "lang": "en",
    "name": "OSU Project Manager",
    "short_name": "Project Manager",
    "scope": "/TSList.aspx",
    "display": "standalone",
    "start_url": "https://gammaprojectmanager.azurewebsites.net/TSList.aspx",
    "theme_color": "#FFE1C4",
    "description": "Time sheet and Clock In/Out",
    "orientation": "portrait-primary",
    "background_color": "#FFE9D2",
    "icons": [
      {
        "sizes": "128x128",
        "src": "/image/icon-128x128.png",
        "type": "image"
      }
    ],
    "screenshots": [],
    "generated": "true"
  }
}

However, when I run the web app and inspect the page, I get these errors: error display

Here is the link that I created to link manifest to master page: <link href="manifest.webmanifest2" rel="manifest" />

The service worker files work, I'm just having trouble with the manifest file.

Upvotes: 4

Views: 9056

Answers (2)

Metro Smurf
Metro Smurf

Reputation: 38335

In web.config, add the .manifest extension as a valid mime type.

<system.webServer>
    <staticContent>
        <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
    </staticContent>
</system.webServer>

If json has not been mapped as a valid mime type (mostly likely already is on the server), then add that as well:

<system.webServer>
    <staticContent>
        <mimeMap fileExtension=".json" mimeType="application/json" />
        <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
    </staticContent>
</system.webServer>

Upvotes: 3

If you are using ASP.NET Core, in Startup.cs in Configure add:

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".webmanifest"] = "application/manifest+json";
    
app.UseStaticFiles(new StaticFileOptions()
{
    ContentTypeProvider = provider
});

Upvotes: 5

Related Questions