Customize azure 403 Forbidden error page for ASP.Net web app

Viewed 139

Please do help me to customize azure 403 forbidden error page for Asp.Net. below is the picture what I am getting, if I return 403 forbidden.

enter image description here

1 Answers

There is a possible workaround: You can route all traffic to your WebApp via your own load balancer or Application Gateway, which allows you to create custom error pages instead of displaying default error pages. You can use your own branding and layout using a custom error page. Please refer to this documentation for further reference.

Using Portal and PowerShell, you can do configure the custom error page.

  1. From Azure Portal > Application Gateways > Listeners > Navigate to particular listener where you want to specify an error page and specify the URL like below:

enter image description here

Using PowerShell for global custom error page:

$appgw   = Get-AzApplicationGateway -Name <app-gateway-name> -ResourceGroupName <resource-group-name>

$updatedgateway = Add-AzApplicationGatewayCustomError -ApplicationGateway $appgw -StatusCode HttpStatus502 -CustomErrorPageUrl "http://<website-url>"

Using PowerShell for a listener level error page:

$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>"

For more information, see Add-AzApplicationGatewayCustomError and Add-AzApplicationGatewayHttpListenerCustomError.

Related