将角度4部署到IIS

时间:2017-08-24 22:09:11

标签: angular iis-7.5

我在Anglular 4中有一个项目,该项目提供从“资产”获取JSON数据的服务。夹。我使用' ng build'创建了dist文件夹。命令然后添加到默认站点下的IIS。在' index.html'中,我设置。

索引页面使用url加载,如 -

http://bla1.bla2.bla3.com/DistFolder

但是,我在我的服务中提到的文件出现了错误,其中包含资产'夹。我在该资产文件夹中有一些jsons和png文件。

我收到如下错误 -

获取http://bla1.bla2.bla3.com/assets/somefile.json 404(未找到)

非常感谢您的帮助。

提前致谢。

1 个答案:

答案 0 :(得分:1)

假设您使用IIS 7.5作为标记而不是更高版本,请确保启用在IIS中提供的JSON mime类型。基本上将web.config添加到根文件夹(index.html所在的位置)中,其中包含:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".json" mimeType="application/json" /> 
        </staticContent>
    </system.webServer>
</configuration>