【发布时间】:2021-12-23 23:04:51
【问题描述】:
【问题讨论】:
-
这能回答你的问题吗? How to set a custom Azure 403 page
标签: asp.net azure error-handling azure-web-app-service
【问题讨论】:
标签: asp.net azure error-handling azure-web-app-service
有一个可能的解决方法: 您可以通过自己的负载均衡器或 应用程序网关 将所有流量路由到您的 WebApp,这样您就可以创建自定义错误页面,而不是显示默认错误页面。您可以使用自定义错误页面来使用自己的品牌和布局。请参阅this 文档以获取更多参考。
使用 Portal 和 PowerShell,您可以配置自定义错误页面。
使用 PowerShell 进行全局自定义错误页面:
$appgw = Get-AzApplicationGateway -Name <app-gateway-name> -ResourceGroupName <resource-group-name>
$updatedgateway = Add-AzApplicationGatewayCustomError -ApplicationGateway $appgw -StatusCode HttpStatus502 -CustomErrorPageUrl "http://<website-url>"
将 PowerShell 用于侦听器级别的错误页面:
$appgw = Get-AzApplicationGateway -Name <app-gateway-name> -ResourceGroupName <resource-group-name>
$listener01 = Get-AzApplicationGatewayHttpListener -Name <listener-name> -ApplicationGateway $appgw
$updatedlistener = Add-AzApplicationGatewayHttpListenerCustomError -HttpListener $listener01 -StatusCode HttpStatus502 -CustomErrorPageUrl "http://<website-url>"
有关详细信息,请参阅Add-AzApplicationGatewayCustomError 和 Add-AzApplicationGatewayHttpListenerCustomError。
【讨论】: