加载.json文件会产生404错误 [英] loading .json files generates 404 errors
问题描述
我的第一个Azure网站是我已经拥有一段时间的简单测试网站,它使ajax回调到服务器以获取JSON数据.所有数据文件均具有.json扩展名. Azure将不会看到"这些文件.如果我将扩展名更改为.txt,则可以正常使用它们.
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.
是否必须使用IIS才能使此.json可见?
Do have to muck with IIS to get this .json to be seen?
推荐答案
我也发现Ahmed Sabbour的博客文章很有帮助,但是这给我带来了另一个问题.当该修补程序适用于Azure Web App时,当我随后尝试在本地运行该应用程序时,该应用程序严重死亡,将HTTP 500.19丢到了各处.我花了一些时间来弄清楚如何在维护单个web.config的同时解决此问题.解决方案是(尽管有些许错误)首先删除fileExtension,然后将其重新添加到以下位置:
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>
出于我的狭purposes目的,这很好,我希望这可以节省某人尝试解决此问题的时间.
For my narrow purposes this was fine and I hope this might save someone time trying to figure this out.
这篇关于加载.json文件会产生404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!