【发布时间】:2021-02-21 01:57:24
【问题描述】:
最近我在我们的测试服务器(IIS 8.0)上托管了一个 Angular(版本 10)网络应用程序。并且还在 IIS 中安装了URL Rewrite Module。
以下是我为规则添加的 web.config。
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect all requests" 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="./index.html" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="true" />
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="/index.html" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="/index.html" />
</customErrors>
</system.web>
</configuration>
但在托管应用程序后,网站正在运行,但不断出现以下错误无法访问网站,如下面的屏幕截图所示。出现错误后,URL 会在几秒钟内自动重新加载,然后网站按预期工作。
以下是我的应用程序池设置。
这个错误的原因是什么?它也在没有空闲时间的情况下发生。我是否缺少任何 IIS 设置?还是需要添加任何其他 URL 编写规则?或者任何设置需要包含在我的角度应用程序中?请帮帮我。
[更新]
借助调试工具发现错误出在angular配置文件中。
【问题讨论】:
-
@LexLi 我认为默认端口 80 已被管理团队禁用。这会是个问题吗?有什么建议可以解决这个问题?
-
除非您的服务器管理员参与,否则任何建议都不会奏效。而是问他们。
-
然后可以使用failed request tracking查看具体内容。
标签: angular iis url-rewriting web-hosting angular-components