我们在 azure 中部署了 Angular 应用程序,但刷新应用程序时出现故障,我们收到错误,即“由于发生内部服务器错误,无法显示页面。”
这是我的 Angular 应用程序中的 web.config 文件
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routing" 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>
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff" />
</customHeaders>
</httpProtocol>
<staticContent>
<mimeMap fileExtension="woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
<mimeMap fileExtension="json" mimeType="application/json" />
</staticContent>
</system.webServer>
<system.web>
<httpCookies httpOnlyCookies="true" requireSSL="true" />
</system.web>
</configuration>
请帮我解决这个问题。
最佳答案
The page cannot be displayed because an internal server error has occurred.
出现此问题的原因是服务器无法访问所请求位置的已配置根目录。
- 确保服务器可以访问所请求位置的已配置根目录。
看起来还有另一个
web.config
与 dist 和 amd 中的父级配置冲突。如果启用了详细错误,500 错误必须找到有问题的
web.config
文件。 在 web.config 中,
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>
- 当使用 Angular 应用程序构建时
ng build --prod
将部署两个 web.config 文件。一个位于根文件夹中,另一个位于 Assets 文件夹中。
- 检查您的
angular.json
文件 如果您发现类似下面的内容
"src/web.config"
删除该行
关于angular - 在 Azure 中部署 Angular 应用程序,但刷新时出现 URL 重写模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71666915/