如何替换默认的Azure 403错误页面

Kru*_*sty 5 asp.net web-config certificate azure

我有一个ASP.NET MVC部署到Azure,用户通过使用客户端证书登录.在本地,如果用户未发送证书或证书无效,则网站会将用户重定向到/ error/403端点.但在Azure上这不起作用:用户没有重定向到/ error/403,显示的页面始终如下: 在此输入图像描述

这是我在<system.webServer>节点内的Web.Config代码:

<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>-->
Run Code Online (Sandbox Code Playgroud)

我还尝试<httpErrors existingResponse="PassThrough" />将代码添加或移动system.webServersystem.web使用customErrors节点,但似乎在读取web.config 之前用户被阻止.对于我尝试过的每一项改变,行为都是一样的.

我怎么解决?谢谢

小智 1

不幸的是,目前 Azure 不支持此功能。应用服务团队的反馈是最近在这篇文章中提供的。但是,通过这篇讨论部署槽的帖子,有一种特定的方法可以解决这个问题。