在Umbraco CMS中创建自定义错误页面

8

我正在为一位客户的网站工作,该网站使用Umbraco作为CMS。我需要创建一个自定义404错误页面。我尝试在IIS配置中进行操作,但umbraco会覆盖掉它。

有人知道如何在Umbraco中创建自定义404错误页面吗? 是否有办法为运行时错误创建自定义错误页面?

5个回答

18
/config/umbracoSettings.config中改变<error404>1</error404>中的"1"为您想要显示的页面的id。
<errors>
   <error404>1</error404> 
</errors>

您可以在未找到处理程序页面中找到其他的实现方法。


您可以通过进入Umbraco管理界面,并在悬停页面上方查看状态来找到页面ID。 - Kearns
2
页面ID位于内容部分的属性选项卡上。 - Echilon

9

如其他帖子所述,根据需要修改错误部分的文化设置。此外,将以下内容添加到web.config中以启用错误传递到Umbraco:

在/config/umbracoSettings.config中(文件本身解释了其用法):

<errors>
  <!-- the id of the page that should be shown if the page is not found -->
  <!--        <errorPage culture="default">1</errorPage>-->
  <!--        <errorPage culture="en-US">200</errorPage>-->
  <error404>2664</error404>
</errors>

在 /web.config 文件中。
<system.webServer>
  <!-- Some other existing stuff -->
  <httpErrors existingResponse="PassThrough" />
</system.webServer>

(注:这是.NET 4)

8
Umbraco也支持文化相关的错误页面,以便您处理多语言站点...
配置更改略有不同。不再是
<errors>
  <error404>1050</error404>
</errors>

现在您需要编写的是

<errors>
  <errorPage culture="default">1</errorPage>-->
  <errorPage culture="en-US">200</errorPage>-->
</errors>

欢呼! /Dirk

1

首先在您的Umbraco安装中创建一个错误页面(和模板)。假设为error.aspx。然后将其发布。 接下来编辑config/umbracoSettings.config

Under <errors> section
    <error404>1111</error404>

其中1111是error.aspx页面的Umbraco节点ID

节点ID可以在内容部分悬停鼠标在错误节点上找到。它通常是一个4位数。

然后编辑web.config

    In <appSettings> section
    change <customErrors mode as show below:
<customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"/>

2
appSettings 部分没有 customErrors 子元素。据我所知,您也不需要修改 customErrors。 - Sprague

0

目前,为了使umbracoSettings.conf在多语言环境下正常工作,必须按以下方式进行配置:

    <errors>
        <!-- the id of the page that should be shown if the page is not found -->
        <!--        <errorPage culture="default">1</errorPage>-->
        <!--        <errorPage culture="en-US">200</errorPage>-->
        <error404>
            <errorPage culture="default">1</errorPage>
            <errorPage culture="ru-RU">1</errorPage>
            <errorPage culture="en-US">2</errorPage>
        </error404>
    </errors>

请注意围绕着errorPage元素的error404元素,以及省略了这个小但重要细节的注释...

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接