Angular 角度应用刷新不';托管在Azure中时无法工作

Angular 角度应用刷新不';托管在Azure中时无法工作,angular,azure,refresh,hosting,Angular,Azure,Refresh,Hosting,该应用程序在本地运行,但当我在Azure上运行它时,每当我按“刷新”时,它都会显示“您正在查找的资源已被删除、名称已更改或暂时不可用” 我找到了一些解决方案,比如将web.config文件放在根文件中,然后将其添加到angular-cli.json文件的资产中,但应用程序根本无法工作,并且显示500个内部服务器错误 如果有人能帮助我,我将不胜感激,因为我已经为此奋斗了很长时间。您应该将web.config移到“src”文件夹,而不是根目录 此外,web.config应该如下所示: <?xm

该应用程序在本地运行,但当我在Azure上运行它时,每当我按“刷新”时,它都会显示“您正在查找的资源已被删除、名称已更改或暂时不可用”

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


如果有人能帮助我,我将不胜感激,因为我已经为此奋斗了很长时间。

您应该将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>


您应该将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>


您是如何托管该页面的?如果找不到路由,您需要确保重定向到
index.html
,如何承载页面?您需要确保重定向到
index.html
如果路由未被发现,则web.config位于src文件夹中,但显然web.config的内容是错误的,因为当我复制您发布的内容时,它正在工作!非常感谢。我的错,web.config在src文件夹中,但显然web.config的内容不好,因为当我复制你发布的内容时,它正在工作!非常感谢。