angular - 在 Azure 中托管时,Angular 应用程序刷新不起作用
问题描述
应用程序在本地工作,但是当我在 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>
推荐阅读
- r - 根据另一个数据帧上的键值重新编码变量
- java - 如何将 3rd 方 JAR 添加到 Maven 项目
- python - 如何从熊猫数据框中只选择几列
- assembly - 在汇编Linux中将浮点值打印到STDOUT
- python - LinearNDInterpolatorExtrapolate 用简单的例子返回错误
- java - 获取异常 java.lang.IllegalStateException: EntityManagerFactory is closed while trying to save secound istance
- c - 如何使用 libpcre2 在纯文本文件中搜索子字符串?
- php - 从 Kartik ExportMenu 小部件导出到 Excel 时,只有在双击它时才会显示换行符
- javascript - 每次登录时如何将url与变量连接起来
- java - 无法使用 Selenium Webdriver 在 Twitter 上的撰写新推文框中输入文本