skip to Main Content

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


  1. I am able to serve the JSON files both locally and from the deployed Azure App Service.

    Check the below steps.

    In VSStudio, Create a new folder in the wwwroot directory and add the .json files.

    enter image description here

    • Deploy the Application to Azure App Service.
    • Make sure your folder is deployed correctly in the sitewwwrootwwwroot folder in KUDU Console.

    enter image description here

    Sample .json Output:

    enter image description here

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search