重定向到Azure应用程序中的自定义错误页面,从未工作

发布于 2025-02-09 13:18:21 字数 670 浏览 2 评论 0 原文

我试图将HTTP错误重定向到外部URL中托管的错误页面,利用元素< httperrors> 在服务器中的Web.config文件中。 目前,我具有以下配置

<configuration>
  <system.webServer>
    <httpErrors errorMode="Custom" defaultResponseMode="Redirect">
      <error statusCode="404" path="https://my-custom-error-page.com" />
    </httpErrors>
  ...

,无论我设置为 defaultresponsemode ,我都无法获取错误页面,相反,我仍在检索IIS错误页面。

有人知道缺少什么吗?


  • IIS版本8.5

I'm trying to redirect in case of an http error to a error page hosted in an external url making use of the element <httpErrors> in my web.config file in server.
Currently I have the following configuration

<configuration>
  <system.webServer>
    <httpErrors errorMode="Custom" defaultResponseMode="Redirect">
      <error statusCode="404" path="https://my-custom-error-page.com" />
    </httpErrors>
  ...

and whatever I set as defaultResponseMode I cannot get the error page, and instead I'm still retrieving always the IIS error page.

someone knows what's missing?


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铜锣湾横着走 2025-02-16 13:18:21

重定向到Azure应用程序服务中的自定义错误页面不起作用

  • ,请确保您的 web.config 已在wwwroot Directory中部署在wwwroot Directory
  • iam中,可以重定向到 code> custom> customeror page with Thens inter Inster设置在 web.config 中,当错误
<httpErrors existingResponse="PassThrough" />
   <httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" path="/public/404.html" responseMode="ExecuteURL" />
    </httpErrors>
  • &lt; System.webserver&gt; 下发生错误时,请确保
<httpErrors existingResponse="PassThrough" />
  • 正确添加了路径
  • wwwroot 文件夹中 文件夹名为public并添加了error.html页面。在web.config中给出相同的路径/public/404.html
  • 尝试访问不存在的页面,它将其重定向到错误页面

Redirecting to custom error pages in Azure Application service doesn't work

  • Make sure your web.config is deployed in the wwwroot directory
  • Iam able to redirect to CustomError page with the below setting in web.config when an error occurs
<httpErrors existingResponse="PassThrough" />
   <httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" path="/public/404.html" responseMode="ExecuteURL" />
    </httpErrors>
  • Under <system.webServer> , Make sure you add
<httpErrors existingResponse="PassThrough" />
  • Check the path correctly
  • Under wwwroot folder created one folder named public and added the error.html page. Give the same path /public/404.html in web.config
  • Tried to access the page which does not exists, it redirected to the error page

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文