angular - Azure 在页面重新加载时出现 Angular 网站问题
问题描述
问题:每当我重新加载除主页面之外的任何页面时,我都会收到 404 Not Found 错误。它只发生在 Azure 上(本地主机工作正常)。我正在使用 Angular 5。这是浏览器在页面重新加载时向我显示的内容:“您要查找的资源已被删除、名称已更改或暂时不可用。”
网站网址: http: //learnwithmentor.azurewebsites.net/
Web.config:https ://github.com/ss-ita/learnwithmentor-server/blob/master/LearnWithMentor/Web.config
解决方案
您可能正在使用 Angular 路由,对吧?您需要添加一些 URL 重写,因为 IIS 当前正在检查您的 URL 指向的文件或目录是否存在。而且由于他们不这样做,它会给您一条错误消息。
这进入你的web.config
下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="/" />
</rule>
</rules>
</rewrite>
推荐阅读
- xaml - 导航页面未在 XAML 中设置 BarBackgroundColor
- r - 如何在 R 中子集从 1.1.1961 到 31.12.2010 的时间段
- sql - 如何标准化一列以便能够解析成多列?
- angular - 取消订阅服务内部的 Observables?
- python - Matplotlib NavigationToolbar 重叠图(在 PyQt4 嵌入中)
- linux-device-driver - 如何使用 ixgbe 从 tcp4 的 RSS 散列中排除端口号
- javascript - 如何将具有相同键的所有值分组到一个数组中
- talend - 从文本文件加载上下文 - 无法读取加载的变量
- android - ImageView 问题,图像不显示或抛出错误
- sql-server - 在 Centos7 上连接 MS SQL 和 PHP 5.6