angular2应用程序,http请求文件json文件,azure上为404 [英] angular2 app, http request for file json file, 404 on azure
问题描述
我正在使用angular2,并且正在执行http get来检索位于http://MYSITE.azurewebsites.net/config/UIVisuals.json
I'm using angular2 and I am doing a http get to retrieve a configuration file that is located at http://MYSITE.azurewebsites.net/config/UIVisuals.json
使用filezilla查看站点时,文件确实存在于wwwroot/config/UIVisuals.json
.
The file does exist at wwwroot/config/UIVisuals.json
when looking at the site with filezilla.
在本地运行时,一切正常.当我部署到天蓝色时,文件上显示404.
When I run locally everything works fine. When I deploy to azure I get a 404 on the file.
如果我将网址放入浏览器The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
If i put the url into the browser The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
更新:
我已经在网站上启用了目录浏览功能,现在可以浏览目录,查看文件.如果我双击它,我会得到The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Updated:
I've enabled directory browsing on my website and I can now browse to the directory, see the file. If I double click it, I get the The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
因此,这有效地使我的应用程序脱离了图片,并使它变得更加蔚蓝.
So this effectively takes my app out of the picture and makes it more of an azure thing.
在这里做什么天蓝色的事情?
推荐答案
更新:我想念您正在尝试提供JSON文件的方法,为此,您需要添加以下mimeMap到您的web.config文件:
Update: I missed that you were trying to serve a JSON file, To make that work, you need to add the following mimeMap to your web.config file:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
See this page for details.
原始答案:
默认情况下,没有任何内容应阻止此类文件被提供.我的猜测是您有一些导致此问题的自定义配置.为了帮助隔离问题,请尝试以下操作:
There is nothing by default that should block such file from being served. My guess is that you have some custom configuration that causes this. To help isolate what, try the following things:
- 如果您将同一文件放在其他文件夹下是否可以使用,例如
config2/UIVisuals.json
? - 如果您创建一个没有其他内容的全新Web应用程序,然后只需添加您的
config/UIVisuals.json
,是否可以使用?
- Is it servable if you put the same file under a different folder, e.g.
config2/UIVisuals.json
? - Is it servable if you create a brand new web app with nothing else in it, and then simply add your
config/UIVisuals.json
?
您应该使用 Kudu控制台进行尝试,因为它比FTP更方便
You should use Kudu Console to try things as it's more convenient than FTP.
这篇关于angular2应用程序,http请求文件json文件,azure上为404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!