Angular 7 Web应用程序页面刷新显示“正在寻找的资源已被删除,名称已更改或暂时不可用。”

时间:2019-03-03 05:12:13

标签: angular7 windows-server-2008-r2 iis-8.5 asp.net-core-2.2

我正在使用Windows Server 2012 R2的IIS中托管的angular 7 Web应用程序。 这是在ASP.NET CORE 2.2上。

当我使用域名导航应用程序时,它可以正常工作,但是如果刷新我访问过的页面,则它会给我“ 您要查找的资源已被删除,名称已更改或暂时被删除。无法使用。

如果我用chrome检查开发人员工具,它会显示以下错误。请参考下图:

Error on Chrome developer tool

user-type-selection:1 是路由路径和参数值。

我试图在 ClientApp src 文件夹中添加 web.config ,并将其作为角的资产。 json 。它将web.config添加到发布文件夹中,但为此,我收到 500个内部服务器错误

有人对此有任何想法吗?

1 个答案:

答案 0 :(得分:0)

此问题已通过web.config中的以下内容解决:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Angular Routes" 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=”/my-app/” /> -->
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

请使用户URL Rewrite extension安装在IIS中。

我之前尝试过上面的web.config,但没有上面的扩展名,因此它给了我500错误。

快乐的编码。