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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With