繁体   English   中英

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

[英]Creating a custom error page in Umbraco CMS

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

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

/config/umbracoSettings.config修改<error404>1</error404>1 ”,其中包含您要显示的页面的ID。

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

其他方法可以在Not found handlers中找到

如其他海报所述,修改错误部分(如果需要,包括文化)。此外,在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)

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

配置稍有变化。 代替

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

你现在写

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

干杯,/德克

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

目前,必须按以下方式配置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>

请注意包含error404元素的errorPage元素,以及省略这个小但重要细节的注释...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM