When I try to access JSON files served through the Azure web app I get 404 (The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.). Almost every resource I managed to find on the internet suggests adding MIME type for .json
extension to the <system.webServer>
section of the web.config
file, like so:
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
or somewhere:
<staticContent>
<remove fileExtension=".json"/>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
But it does not work for me.
Indeed, when I go to the Kudu console and log staticContent
section with the following command:
%windir%System32inetsrvappcmd list config /section:staticContent
it shows what I assume is the correct MIME type for JSON files (<mimeMap fileExtension=".json" mimeType="application/json" />
).
However, trying to access https://appname.azurewebsites.net/some-folder/example.json returns 404. I tried placing other files inside the same directory (txt, css, js, png, font files, etc) and they are all served without any trouble, except for the JSON.
I really don’t know how to approach this any further and I would appreciate some help here.
2
Answers
I am able to serve the
JSON
files both locally and from the deployedAzure App Service
.Check the below steps.
In
VSStudio
, Create a new folder in thewwwroot
directory and add the.json
files.Azure App Service
.sitewwwrootwwwroot
folder in KUDU Console.Sample .json Output:
You need to make sure that the JSON file you are trying to access exists in the correct directory on the server. Try clearing your browser cache and reloading the page to see if the JSON file is served correctly.
Also, you can enable Failed Request Tracing to capture detailed errors in IIS, it will provide key errors and warnings which will help you identify the problem.
This is a reference document: Troubleshooting Failed Requests Using Tracing in IIS