Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How replace the default Azure 403 error page

I've got an ASP.NET MVC deployed to Azure and users login though the use of client certificate. Locally, if the user don't send a certificate or it's invalid, the website redirects the user to /error/403 endpoint. But on Azure this doesn't work: the user is not redirect to /error/403 and the page displayed is always this: enter image description here

This is my Web.Config code inside <system.webServer> node:

<httpErrors errorMode="Custom" existingResponse="Replace">
  <clear />
  <error statusCode="400" path="/error/400" responseMode="Redirect" />
  <error statusCode="404" path="/error/404" responseMode="Redirect" />
  <error statusCode="500" path="/error/500" responseMode="Redirect" />
  <error statusCode="501" path="/error/501" responseMode="Redirect" />
  <error statusCode="503" path="/error/503" responseMode="Redirect" />
</httpErrors>-->

I've also tried to add <httpErrors existingResponse="PassThrough" /> or move my code from system.webServer to system.web using customErrors nodes, but it seems that the user is blocked before the web.config has been read. The behavior remained the same for every change I've tried.

How can I solve? Thanks

like image 444
Krusty Avatar asked Nov 07 '22 21:11

Krusty


1 Answers

Unfortunately, this is not supported feature by Azure as of right now. The feedback from App Service Team is pretty recent in this post. However, there is a certain way to get around it via this post talking about deployment slots.

like image 106
Kelv.Gonzales Avatar answered Nov 16 '22 17:11

Kelv.Gonzales