托管在Azure中时,Angular应用程序刷新不起作用

时间:2018-09-07 17:18:11

标签: angular azure refresh hosting

应用程序在本地运行,但是当我每按一次刷新将其托管在Azure上时,它会显示“您正在寻找的资源已被删除,名称更改或暂时不可用。”

我找到了一些解决方案,例如将web.config文件放入根文件,并将其添加到angular-cli.json文件的资产中,但是随后应用程序根本无法工作,并显示500个内部服务器错误。

如果有人可以帮助我,我将不胜感激,因为我已经为此苦苦挣扎了很长一段时间。

1 个答案:

答案 0 :(得分:1)

您应将web.config移至“ src”文件夹,而不要移至根目录。

而且web.config看起来应该像这样:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Angular4" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

摘自该帖子:angular 2 azure deploy refresh error : The resource you are looking for has been removed, had its name changed, or is temporarily unavailable