如何替换默认的 Azure 403 错误页面
How replace the default Azure 403 error page
我已将 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>-->
我也尝试使用 customErrors
节点添加 <httpErrors existingResponse="PassThrough" />
或将我的代码从 system.webServer
移动到 system.web
,但似乎用户被阻止了 之前 web.config 已被阅读。对于我尝试过的每一次更改,行为都保持不变。
我该如何解决?谢谢
您的网站似乎不是 运行。
Azure 网站停止的可能原因有 3 种:
- 已达到计费限额,您的站点已被禁用。
- 它已在门户中停止。
- 它已达到适用于免费或共享缩放模式的资源配额限制。
请检查 Azure 门户是否存在这些情况。
遗憾的是,Azure 目前不支持此功能。应用服务团队的反馈最近在这个 post. However, there is a certain way to get around it via this 讨论部署槽中。
我已将 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>-->
我也尝试使用 customErrors
节点添加 <httpErrors existingResponse="PassThrough" />
或将我的代码从 system.webServer
移动到 system.web
,但似乎用户被阻止了 之前 web.config 已被阅读。对于我尝试过的每一次更改,行为都保持不变。
我该如何解决?谢谢
您的网站似乎不是 运行。
Azure 网站停止的可能原因有 3 种:
- 已达到计费限额,您的站点已被禁用。
- 它已在门户中停止。
- 它已达到适用于免费或共享缩放模式的资源配额限制。
请检查 Azure 门户是否存在这些情况。
遗憾的是,Azure 目前不支持此功能。应用服务团队的反馈最近在这个 post. However, there is a certain way to get around it via this