Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • YM 2 posts 22 karma points
    Dec 12, 2014 @ 10:59
    YM
    0

    Customize 404 page does not work.

    Hi umbraco team.

    I have failed to do customized 404 page with umbraco 4.7.2. I am working on a site with multiple languages. All languages missing pages redirect to English error page(the node I would like English to display) instead of localized error page. Can someone help here? much appreciated.

    I have followed exactly same steps as http://our.umbraco.org/wiki/install-and-setup/configuring-404-pages# suggests. Below is my steps: 1.Umbraco->Settings->Languages. Adding several languages. such as English, Chinese simplified, Vietnamese, Korean.

    2.Content: at each local node, select "manage host name", add new domain and associated with proper language. content structure

    3.Open the configuration file /config/umbracosettings.config and look for the element

    4.at system.webServer section of the web.config, add below in system.webServer section. enter image description here

    after these steps. All languages missing pages redirect to English error page(the node I would like English to display) instead of localized error page.

    below is my investigation: 1.first I think it might not recognize the language culture. so I using below code to get culture alias. and get vi-VN,zh-CN,en-US correctly. culture alias can not get for local node not associated with language which is expected. @inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.cms.businesslogic.web;

    @{ var firstDomainLanguage = Domain.GetDomainsById(Model.AncestorOrSelf(1).Id)[0].Language; }

    @firstDomainLanguage.CultureAlias

    2.in DB, I run below: select * from dbo.umbracoLanguage and interesting thing is I can get languageISOCode for all language. But for languageCultureName only en-US showed, other language shows "NULL" for languageCultureName . So Is there something wrong with umbraco itself? After I updated the languageCultureName to zh-CN,vi-VN separately. restart app in app pool. and still have the same problem.

    3.If I update /config/umbracosettings.config to below(just remove en-us section): and now error page looks like below:

    "Page not found

    No umbraco document matches the url 'http://localhost:8085/zh-cn/lafdgrgr'

    umbraco tried this to match it using this xpath query'/root/* [@urlName = "zh-cn"]/* [@urlName = "lafdgrgr"]')

    This page can be replaced with a custom 404 page by adding the id of the umbraco document to show as 404 page in the /config/umbracoSettings.config file. Just add the id to the '/settings/content/errors/error404' element.

    For more information, visit information about custom 404 on the umbraco website.

    This page is intentionally left ugly ;-)"

    4.then I tried to rewrite own 404 handler referred to http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler. But still it does not work. 1).below is code:

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using umbraco.interfaces;

    namespace HaigClub { public partial class Custom404 : INotFoundHandler { private int _redirectID = -1;

        public bool CacheUrl
        {
            get { return false; }
        }
    
        public bool Execute(string url)
        {
            var CurrentUrl = HttpContext.Current.Request.Url.ToString().ToLower();
            if (CurrentUrl.IndexOf("en-row") > -1)
            {
                _redirectID = 1111; //the id of the en-row 404 page.
                return true;
            }
            else if(CurrentUrl.IndexOf("zh-cn") >-1)
            {
                _redirectID = 2222; //the id of the zh-cn 404 page.
                return true;
            }
            else if (CurrentUrl.IndexOf("vi-vn") > -1)
            {
                _redirectID = 3333; //the id of the vi-vn 404 page.
                return true;
            }
            else if (CurrentUrl.IndexOf("en-gb") > -1)
            {
                _redirectID = 4444; //the id of the en-gb 404 page.
                return true;
            }
            else if (CurrentUrl.IndexOf("ko-kr") > -1)
            {
                _redirectID = 5555; //the id of the ko-kr 404 page.
                return true;
            }
            else
            {
                _redirectID = 6666; //the id of the vi-vn 404.
                return true;
            }
        }
        public int redirectID
        {
            get
            { return _redirectID; }
        }      
    }
    

    } 2).in /config/404handlers.config. Adding below: 3).Deploy the 404hander dll to the site.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Dec 14, 2014 @ 19:22
    Jan Skovgaard
    0

    Hi YM and welcome to our :)

    Any chance that you're perhaps using ucomponents on your site? If not then make sure to download version 4.10, which is the latest compatible version with Umbraco 4.7.2, which you can download here http://ucomponents.codeplex.com/releases/view/93259 - There have been done several newer releases but they're not compatible with 4.7.2.

    But the benefit of ucomponents is that it contains so much nice stuff that makes it easier to deal with all different kinds of stuff.

    And in your case it sounds like you can benefit from using the multisite not found handler, which allows you to create picker, where you can let the editors choose a page to be displayed if the user should come across a 404. You can read more about it here https://ucomponents.codeplex.com/wikipage?title=MultiSitePageNotFoundHandler

    Make sure to keep a backup of your files and database before installing though so we're sure it's easy to rollback if something should not go as planned.

    Hope this helps.

    /Jan

  • YM 2 posts 22 karma points
    Dec 15, 2014 @ 09:22
    YM
    0

    Hi Jan,

    thanks a lot for your input and info. unfortunately it still does not work using the ucomponents. So am I missing something?

    I installed ucomponents 4.10 an enable "MultiSitePageNotFoundHandler" and followed https://ucomponents.codeplex.com/wikipage?title=MultiSitePageNotFoundHandler&referringTitle=NotFoundHandlers.

    1.below is the site structure. document type of "en-row","zh-cn","vi-vn","en-gb","ko-kr" is called as "Local", so I added a new property: Content Picker property (with the alias of "umbracoPageNotFound") to document type "Local".

    enter image description here

    2.On the front-end, at "en-row"/"zh-cn"/"vi-vn"...., populated the umbracoPageNotFound with the localized error 404 page.

    3.checking at /config/404handlers.config seems below have been already added so I did not change anything.

    enter image description here

    thanks, YM

Please Sign in or register to post replies

Write your reply to:

Draft