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

发布于 2024-07-05 11:34:04 字数 165 浏览 8 评论 0原文

我正在开发一个使用 Umbraco 作为 CMS 的客户网站。 我需要创建一个自定义 404 错误页面。 我尝试在 IIS 配置中执行此操作,但 umbraco 覆盖了它。

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

I'm working on a client site who is using Umbraco as a CMS. I need to create a custom 404 error page. I've tried doing it in the IIS config but umbraco overrides that.

Does anyone know how to create a custom 404 error page in Umbraco?
Is there a way to create a custom error page for runtime errors?

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

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

发布评论

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

评论(5

臻嫒无言 2024-07-12 11:34:04

/config/umbracoSettings.config 中,将 1 "1" 修改为您想要的页面 ID展示。

<errors>
   <error404>1</error404> 
</errors>

其他方法可以在 未找到处理程序

In /config/umbracoSettings.config modify <error404>1</error404> "1" with the id of the page you want to show.

<errors>
   <error404>1</error404> 
</errors>

Other ways to do it can be found at Not found handlers

葬花如无物 2024-07-12 11:34:04

正如其他发帖者所述,按照指示修改错误部分(如果需要,包括区域性。)此外,在 Web 配置中添加以下内容以启用错误传递到 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)

As stated by other posters, modify the errors section as indicated (including culture if needed.) In addition, add the following in the web config to enable passthrough of errors to umbraco:

In /config/umbracoSettings.config (the file itself explains its usage):

<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>

In /web.config

<system.webServer>
  <!-- Some other existing stuff -->
  <httpErrors existingResponse="PassThrough" />
</system.webServer>

(Note: This is .NET 4)

御守 2024-07-12 11:34:04

umbraco 还支持文化相关的错误页面,以防您使用多语言网站...

配置发生了一点点变化。 而不是

<errors>
  <error404>1050</error404>
</errors>

你现在写

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

干杯,
/短剑

umbraco also supports culture dependent error pages in case you're working with multilingual sites...

Config changes a tiny bit. Instead of

<errors>
  <error404>1050</error404>
</errors>

you'd now write

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

Cheers,
/Dirk

榕城若虚 2024-07-12 11:34:04

首先在 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"/>

First create an error page (and template) in your umbraco installation. Let us say error.aspx. Publish it.
Then edit config/umbracoSettings.config.

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

Where 1111 is the umbraco node ID for the error.aspx page

Node ID can be found by hovering mouse on the error node in content section. It's usually a 4 digit number.

Then edit the web.config:

    In <appSettings> section
    change <customErrors mode as show below:
<customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"/>
2024-07-12 11:34:04

目前,必须按以下方式配置 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 元素code> 元素,以及省略这个小而重要的细节的注释......

Currently umbracoSettings.conf has to be configured the following way in order to make it work in a multilingual way:

    <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>

Please note the error404 element which surrounds the errorPage elements, as well as the comments omitting this small yet important detail...

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