Kurkula
Kurkula

Reputation: 6762

Unable to open Json file on Server

I published a json file on to my website using ftp. When I tried to access my site using mtsite.com/abc.json it throws the below error.

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

My file is on hosted site on azure. Even if file in on server why did it say that file is not found?

Any place in azure portal where I can add or allow Mime type json? I cannot add web.config file as My files are all HTML and Json.

Upvotes: 2

Views: 2299

Answers (1)

Lorenzo Montanari
Lorenzo Montanari

Reputation: 968

By default IIS (and so the Azure App Service) doesn't serve .json files. You need to enable this feature in your web.config. If don't already have one, create it in the root directory.

Open your web.config and place this code

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

under the nodes

<configuration>
   <system.webServer>

And it should be fixed.

Here you can find a basic web.config template that i've made a while ago

P.S: Even though you are using only HTML and JSON, this is the only way to go (as there is not a UI solution in the portal). In this way you could also control other aspect of your website, for example the redirect to HTTPS for the HTTP requests.

Upvotes: 7

Related Questions