简体   繁体   中英

Creating a custom error page in Umbraco CMS

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?

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

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)

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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