Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loading .json files generates 404 errors

Tags:

json

azure

My first Azure website is a simple test site I've had for a while that makes ajax calls back to the server for JSON data. All the data files have .json extensions. Azure will not 'see' these files. If I change the extension to .txt it servers them up fine.

Do I have to muck with IIS to get this .json to be seen?

like image 596
Pablo Avatar asked Sep 11 '12 22:09

Pablo


People also ask

Where is the JSON file in IIS?

The file is in the specified location in the web directory structure. The MIME Type .json has been added as application/json. I did this 2 different ways, using the IIS Management Console, and by adding it to the Web Config using a remove followed by the tag to add it.

How to get an API problem response from a jsonresponse?

Back in configureListeners, the rest is exactly like before: use ApiProblem to create a JsonResponse and set the application/problem+json Content-Type header on it. Now, if an exception is thrown from anywhere in the system for a URL beginning with /api, the client will get back an API problem response.

How to add MIME type JSON in IIS?

The MIME Type .json has been added as application/json. I did this 2 different ways, using the IIS Management Console, and by adding it to the Web Config using a remove followed by the tag to add it. I have also added other file types, PNG, html right next to it in the same directory with the same permissions. They load just fine.

What is the name of the JSON file used for translation?

The JSON file is named translation-en.json. I've scoured stackoverflow for similar issues and tried everything I can find. I've worked with the vendor for the component that needs to load the file using fetch. Tried all of their suggestions.


1 Answers

I too found Ahmed Sabbour's blog post helpful, but it created an additional problem for me. Whilst the fix worked for the Azure Web App when I then tried to run the app locally it died horribly, throwing HTTP 500.19 everywhere. It took me a while to figure out how to fix this whilst maintaining a single web.config. The solution was (albeit a bit of a fudge) to remove the fileExtension first and then add it back in:

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

For my narrow purposes this was fine and I hope this might save someone time trying to figure this out.

like image 191
Mike Rouse Avatar answered Oct 01 '22 03:10

Mike Rouse