【问题标题】:Customize azure 403 Forbidden error page for ASP.Net web app为 ASP.Net Web 应用程序自定义 azure 403 Forbidden 错误页面
【发布时间】:2021-12-23 23:04:51
【问题描述】:

请帮我为 Asp.Net 定制 azure 403 禁止错误页面。下面是我得到的图片,如果我返回 403 禁止。

【问题讨论】:

标签: asp.net azure error-handling azure-web-app-service


【解决方案1】:

有一个可能的解决方法: 您可以通过自己的负载均衡器或 应用程序网关 将所有流量路由到您的 WebApp,这样您就可以创建自定义错误页面,而不是显示默认错误页面。您可以使用自定义错误页面来使用自己的品牌和布局。请参阅this 文档以获取更多参考。

使用 PortalPowerShell,您可以配置自定义错误页面。

  1. 从 Azure 门户 > 应用程序网关 > 侦听器 > 导航到要指定错误页面的特定侦听器并指定如下 URL:

使用 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-AzApplicationGatewayCustomErrorAdd-AzApplicationGatewayHttpListenerCustomError

【讨论】:

  • 如果回答对您有帮助,请Accept it as an Answer,以便遇到相同问题的其他人可以找到此解决方案并解决他们的问题。
猜你喜欢
  • 1970-01-01
  • 2016-12-21
  • 1970-01-01
  • 2019-06-15
  • 2018-12-20
  • 1970-01-01
  • 1970-01-01
  • 2012-01-31
  • 1970-01-01
相关资源
最近更新 更多