Copied to clipboard

Flag this post as spam?

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


  • Max 7 posts 27 karma points
    Jan 03, 2013 @ 14:06
    Max
    0

    404 pages for multylanguage site problem(ucomponents)

    Hi all.

    I have same site structure(see image)

    I use ucomponents solution for 404 error

    That solution works for number 1 and 4 but for 2 and 3 showed default 404 error.

    This is result(all are setup correctly)

    Anyone encountered with problem like this?

    Thanks in advance.

  • Iulia Maria Jensen 40 posts 71 karma points
    Jan 03, 2013 @ 14:42
    Iulia Maria Jensen
    0

    Hi,

    Do you have access to the config/umbracoSettings.config file?

     

  • Max 7 posts 27 karma points
    Jan 03, 2013 @ 14:55
    Max
    0

    Yes. I have access for all project files(by permissions and physically).

  • Iulia Maria Jensen 40 posts 71 karma points
    Jan 03, 2013 @ 14:59
    Iulia Maria Jensen
    0

    In this case, you could use the umbracoSettings.config file to specify which node should be shown as an error page (as long as you have your error pages as nodes).

    For example:

            <errors>

      <error404>

    <errorPage culture="default">1133</errorPage>

    <errorPage culture="fr-FR">11202</errorPage>

    </error404>

            </errors>

    You should also make sure that you apply the right language for the nested "website" and that you specify the right culture code (as seen in the example).

    This is the version without the ucomponents help (manual setup).

    Let me know if this helps you.

    Kind regards, Iulia

  • Max 7 posts 27 karma points
    Jan 03, 2013 @ 15:13
    Max
    0

    I can't use that because I have two sites with equal culture

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 03, 2013 @ 15:34
    Lee Kelleher
    0

    Hi Max,

    Do nodes "2) Dutch" and "3) French" have a domain/hostname associated with them?

    Cheers, Lee.

  • Max 7 posts 27 karma points
    Jan 03, 2013 @ 16:26
    Max
    0

    Home pages have url like:

    2) domain/nl/

    3) domain/fr/

  • Sébastien Richer 194 posts 430 karma points
    Jan 03, 2013 @ 17:26
    Sébastien Richer
    0

    Hi Max,

    Did you "Manage hostnames" for those nodes? I use this module in multi-site multiple language setups and it works well.

    Look in 404handlers.config, here is what I have :

    <?xml version="1.0" encoding="utf-8" ?>
    <NotFoundHandlers>
      <notFound assembly="umbraco" type="SearchForAlias" />
      <notFound assembly="umbraco" type="SearchForTemplate"/>
      <notFound assembly="umbraco" type="SearchForProfile"/>
      <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />
      <notFound assembly="umbraco" type="handle404"/>
    </NotFoundHandlers>

    And for example my setups is:

    Site A
      - FR (Managed hostname for fr.sitea.com) --> Content picker to the node below
        - Erreur 404 (in FR)
      - EN (Managed hostname for fr.sitea.com) --> Content picker to the node below
       - Error 404 (in EN) 

    Hope this helps!

    Seb

  • Max 7 posts 27 karma points
    Jan 03, 2013 @ 18:02
    Max
    0

    Sébastien, I'm already using this solution. But it doesn't work on site with language selection page.

     

    thx

  • Sébastien Richer 194 posts 430 karma points
    Jan 03, 2013 @ 18:12
    Sébastien Richer
    0

    Hi Max,

    I have this same situation, with a language selection page, see here : lolitacocktails.com.

    I remember I had to use subdomains instead of /fr/ and /en/ because the cultre was not set properly otherwise for dictionary labels.

    So my structure:

    Site A (Manage hostnames: lolitacocktails.com and www.lolitacocktails.com)
      - FR (Manage hostnames: fr.lolitacocktails.com)
      - EN (Manage hostnames: en.lolitacocktails.com) 

    Site B (Repeat with another domain)

    Site C (Repeat, I have 4 sites right now)

    To test this is local, I use the windows hosts file and variations like this fr.lolitacocktails.local and have to adjust the manage hostnames properties accordingly.

    My Site A node defaults to the FR error 404 page through the content picker.

    In your example, 1, 2, 3 and 4 are all the same site? Should you have a setup like this instead :

    Site A
      - Lang 1 
      - Lang 2
      - Lang 3
      - Lang 4

    Hope this helps!

    Seb 

     

  • Max 7 posts 27 karma points
    Jan 04, 2013 @ 12:55
    Max
    0

    Hi, Sébastien.

    I use structure like this:

    1)otherdomain.nl

    2)domain.be

    -3)domain.be/nl

    -4)domain.be/fr

    5)domain.nl

  • Sébastien Richer 194 posts 430 karma points
    Jan 04, 2013 @ 16:30
    Sébastien Richer
    0

    Hi max,

    Ok so here are a couple of questions.

    1: otherdomain.nl
    - What is the language?
    - You have the "umbracoPageNotFound" content picker for the 404 page here? What is it set to? 
    2: domain.be
    - This is a language selection page right?
    - What "default" language do you set here?
    - You have the "umbracoPageNotFound" content picker for the 404 page here? What is it set to?
    3: domain.be/nl
    - You have the "umbracoPageNotFound" content picker for the 404 page here? What is it set to?
    4: domain.be/fr
    - You have the "umbracoPageNotFound" content picker for the 404 page here? What is it set to?
    5: domain.nl
    - This one will actually be the same page as domain.be/nl is that right?
    - If so, I would do a redirection rule like this, domain.nl/(*.) --> domain.be/nl/(*.)

    Nodes 3 and 4 should give you the appropriate 404 page if your "umbracoPageNotFound" content picker is correctly set.

    Hope this helps

    Seb

  • Max 7 posts 27 karma points
    Jan 08, 2013 @ 08:54
    Max
    0

    Hi Sébastien 

    1: otherdomain.nl
    Dutch (Netherlands)
    umbracoPageNotFound exist and contains node from this site
    2: domain.be
    - this is a language selection page
    English (United States)
    - I don't have umbracoPageNotFound here
    3: domain.be/nl
    umbracoPageNotFound exist and contains node from this site
    4: domain.be/fr
    umbracoPageNotFound exist and contains node from this site
    5: domain.nl
    - No. This is another site.

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 10, 2013 @ 08:10
    Simon Dingley
    0

    I'm also having problems however one thing to note is that the handlers are now located in their own assemblies and so the entry in your config I think should be:

    <notFound assembly="uComponents.NotFoundHandlers" type="uComponents.MultiSitePageNotFoundHandler" />

    Is this correct Lee?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 10, 2013 @ 11:11
    Lee Kelleher
    2

    Hi Simon,

    The "type" value doesn't need the "uComponents" bit at the start.  The core code concats the "assembly" and "type" when it does a look-up.

    <notFound assembly="uComponents.NotFoundHandlers" type="MultiSitePageNotFoundHandler" />

    Cheers, Lee.

  • Sébastien Richer 194 posts 430 karma points
    Jan 10, 2013 @ 15:15
    Sébastien Richer
    0

    Hi Max,

    Sorry for the delayed response, seems I did'nt get the notification email. Ok, all looks good, I think the last thing I could tell you to check is in your web.config, look for:

    <system.webServer>
        <httpErrors existingResponse="PassThrough" />

    This setting should be set to PassThrough to allow custom errors. While were in web.config, also look for:

    <system.web>
        <customErrors defaultRedirect="GenericError.htm" mode="On" redirectMode="ResponseRewrite">
          <error statusCode="500" redirect="~/500.aspx" />
        </customErrors>

    The important part here (ignore stuff about 500) is the mode="On". Look for that also, to allow custom errors like you want, you need that.

    Hope this helps, otherwise, I'm running out of ideas, sorry!

    Seb

     

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 10, 2013 @ 15:17
    Simon Dingley
    0

    Lee's solution above worked for me in my multi-site installation.

  • Amir Khan 1287 posts 2744 karma points
    Jun 21, 2013 @ 22:31
    Amir Khan
    0

    Has anyone had an issue where this works until you change a hostname then just stops?

  • Maria 34 posts 128 karma points
    May 28, 2014 @ 11:04
    Maria
    0

    We are having a similar problem. We have several sites in one Umbraco installation (v. 4.11.8). Each site has a domain and a culture (although cultures are the same for all of them) and a umbracoPageNotFound picker. 

    Locally and on our stage server everything works fine but on production server SOME of the sites go to the default "Site not found"-page instead of using the chosen nodes.

    I checked all the above suggestions and the only difference I can see in our solution is that in 404handlers.config we use 

      <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />

    But it seems to work locally so I guess that is not the problem. It seems we also have this problem in some other solutions we are running.

    Do you have any suggestions? Can it be server settings of some kind? Or is it a bug? 

    Thanks in advance. 

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    May 28, 2014 @ 11:11
    Lee Kelleher
    1

    Hi Maria,

    Couple of things to check:

    • Which version of uComponents are you using? If it's earlier than v5.x, then your config is correct. If it's v5.x or above, then try this instead:

      <notFound assembly="uComponents.NotFoundHandlers" type="MultiSitePageNotFoundHandler" />


    • Check the config/umbracoSettings.config file, make sure that the web.routing/@trySkipIisCustomErrors is set to "true":

      <web.routing trySkipIisCustomErrors="true" internalRedirectPreservesTemplate="false"></web.routing>

      I got caught out with the trySkipIisCustomErrors setting only yesterday.

    Cheers,
    - Lee

  • firepol 125 posts 173 karma points
    Jun 06, 2014 @ 11:09
    firepol
    0

    This drives me crazy, I have a multi domain website with multi-language, like this:

    siteA
    -en-US
    -de-DE

    siteB
    -en-US
    -de-DE

    Server: Windows Server Standard with Service Pack 2 installed. 64 bit.

    IIS: 6.0, Build 6002 (Service Pack 2).

    Is there an updated tutorial/guide on how to make these error pages work in this setup?

    I did as explained in the uComponents Multi-site Page Not Found page:

    • Visual Studio 2012 solution, .net 4.5 MVC empty project, umbraco added via Nuget, umbraco set as "Mvc"
    • installed uComponents (6.0.0) via NuGet
    • "home" nodes (the ones where the "Culture and Hostnames" are configured) I added a new "Content Picker" property with alias "umbracoPageNotFound"
    • added an error page for every domain/culture
    • picked for every domain/culture "home" the error page with the "umbracoPageNotFound" content picker and saved & published
    • added in /config/404handlers.config, before the "handle404" entry:
    <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />
    • recycled the IIS application pool as instructed (a web.config modification is not enough?)

     

    When I browse, say to siteA/en/test (test does not exist) I get the default IIS 404 error page, I have to edit config/umbracoSettings.config and set "trySkipIisCustomErrors" to true as mentioned by Lee, but still even so I get the default umbraco error page intentionally left ugly:

    Page not found
    No umbraco document matches the url '/en/test'.

    This page can be replaced with a custom 404. Check the documentation for "custom 404".

    This page is intentionally left ugly ;-)

     

    If the config/umbracoSettings.config "trySkipIisCustomErrors" setting is important to make things work, then please update the Multi-site Page Not Found guide and put it there...

     

    I did some more tests... if I comment in the 404handlers.config the umbraco 404 handler, and let only the ucomponents one, like this:

    <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />
    <!--<notFound assembly="umbraco" type="handle404"/>-->

    I get (in web.config I must have <customErrors mode="Off" />) this error:

    Server Error in '/' Application.
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [NullReferenceException: Object reference not set to an instance of an object.]
       System.Object.GetType() +0
       Umbraco.Web.Routing.ContentLastChanceFinderByNotFoundHandlers.HandlePageNotFound(PublishedContentRequest docRequest) +182
       Umbraco.Web.Routing.ContentLastChanceFinderByNotFoundHandlers.TryFindContent(PublishedContentRequest docRequest) +16
       Umbraco.Web.Routing.PublishedContentRequestEngine.HandlePublishedContent() +492
       Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContentAndTemplate() +264
       Umbraco.Web.Routing.PublishedContentRequestEngine.PrepareRequest() +106
       Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext) +513
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18067

    If I add in the web.config, in <system.webServer>, as mentioned by Lee:

    <httpErrors existingResponse="PassThrough" />

    I get this error:

    The page cannot be displayed because an internal server error has occurred.

    I suspect this happens because it's IIS 6? Anyway, I tried a bit everything, and it doesn't work for my setup.

    I also tried, in umbracoSettings.config, to comment the <errors> section... then I get this error:

    Server Error in '/' Application.
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [NullReferenceException: Object reference not set to an instance of an object.]
       umbraco.library.GetCurrentNotFoundPageId() +57
       Umbraco.Web.Routing.ContentFinderByLegacy404.TryFindContent(PublishedContentRequest pcr) +79
       Umbraco.Web.Routing.ContentLastChanceFinderByNotFoundHandlers.HandlePageNotFound(PublishedContentRequest docRequest) +1241
       Umbraco.Web.Routing.ContentLastChanceFinderByNotFoundHandlers.TryFindContent(PublishedContentRequest docRequest) +15
       Umbraco.Web.Routing.PublishedContentRequestEngine.HandlePublishedContent() +491
       Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContentAndTemplate() +263
       Umbraco.Web.Routing.PublishedContentRequestEngine.PrepareRequest() +105
       Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext) +512
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18067

     

    My conclusions: <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" /> doesn't work. I tried also to put MultiSitePageNotFoundHandler or SearchForPageNotFound, it didn't do any difference. It's like not having it there at all.

    I tried to check again my home document types. The property is there,"Content Picker", alias umbracoPageNotFound, name also umbracoPageNotFound just to be sure.

    Please please please help me, or should I say to my customer that we have to use the same HTML error page for both of the websites we have? That would be a pity. I want to make things work properly, I count on you! ;)

    Thank you...

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 06, 2014 @ 12:05
    Dave Woestenborghs
    0

    I don't know what version of uComponents you are using but I have this working in 4.7.2 with ucomponents.

    The only difference I see is this:

    <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 06, 2014 @ 12:07
    Dave Woestenborghs
    0

    I see in the documentation that my notFound setting should be the correct one :

    http://ucomponents.codeplex.com/wikipage?title=MultiSitePageNotFoundHandler&referringTitle=Documentation

  • firepol 125 posts 173 karma points
    Jun 06, 2014 @ 12:21
    firepol
    0

    Hi dawoe, I'm using uComponents 6.0.0 as specified in my reply.

    Sorry, when I wrote my reply, I wrongy copied/pasted it. but in my tests I copied/pasted from the guide, so it was the correct one. I also edited my reply, I used in any case this one:

    <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />

    still not working.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 06, 2014 @ 12:29
    Dave Woestenborghs
    0

    Are your sites located under the root of the content tree ?

  • firepol 125 posts 173 karma points
    Jun 06, 2014 @ 12:34
    firepol
    0

    Yes, the home nodes are directly located under "Content", so in my case:

    Content
    -SiteA (en) Culture Hostname properly configured Language/Culture: en-US, Domain: http://sitea/en
    -SiteA (de) Culture Hostname properly configured Language/Culture: de-DE, Domain: http://sitea/de
    -SiteB (en) Culture Hostname properly configured Language/Culture: en-US, Domain: http://siteb/en
    -SiteB (de) Culture Hostname properly configured Language/Culture: de-DE, Domain: http://siteb/de

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 06, 2014 @ 12:37
    Dave Woestenborghs
    0

    Can you post your entire 404handlers.config

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 06, 2014 @ 12:39
    Dave Woestenborghs
    0

    And also can you check your log for info when you try to get a 404 page. There is sometimes usefull information in there.

  • Bogdan 250 posts 427 karma points
    Jun 06, 2014 @ 12:44
    Bogdan
    0

    I got the not found handler to work by getting the source from here https://github.com/uComponents/uComponents/blob/master/src/uComponents.NotFoundHandlers/MultiSitePageNotFoundHandler.cs

    Debugging helped me find out what was not working and what to change, but unfortunately I don't remember what it was :(

    Just dropped MultiSitePageNotFoundHandler.cs in the root, changed the namespace and added in 404handlers.config

  • Bogdan 250 posts 427 karma points
    Jun 06, 2014 @ 12:48
    Bogdan
    2

    Aha, I found it!

    using System;
    using System.Net;
    using System.Web;
    using umbraco;
    using umbraco.cms.businesslogic.web;
    using umbraco.interfaces;
    using umbraco.NodeFactory;
    
    namespace NAMESPACE
    {
        /// <summary>
        /// A NotFoundHandler for multiple web-site set-up.
        /// </summary>
        public class MultiSitePageNotFoundHandler : INotFoundHandler
        {
            /// <summary>
            /// Field to store the redirect node Id.
            /// </summary>
            private int _redirectId = uQuery.RootNodeId;
    
            /// <summary>
            /// Gets a value indicating whether [cache URL].
            /// </summary>
            /// <value><c>true</c> if [cache URL]; otherwise, <c>false</c>.</value>
            public bool CacheUrl
            {
                get
                {
                    return false;
                }
            }
    
            /// <summary>
            /// Gets the redirect ID.
            /// </summary>
            /// <value>The redirect ID.</value>
            public int redirectID
            {
                get
                {
                    return this._redirectId;
                }
            }
    
            /// <summary>
            /// Executes the specified URL.
            /// </summary>
            /// <param name="url">The URL.</param>
            /// <returns>Returns whether the NotFoundHandler has a match.</returns>
            public bool Execute(string url)
            {
                HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.NotFound;
    
                var success = false;
    
                // get the current domain name
                var domainName = GetFullyQualifiedApplicationPath(HttpContext.Current) + url.Split('/')[0];
    
                // get the root node id of the domain
                var rootNodeId = Domain.GetRootFromDomain(domainName);
    
                try
                {
                    if (rootNodeId <= 0)
                    {
                        rootNodeId = uQuery.GetRootNode().Children[0].Id;
                    }
    
                    // get the node
                    var node = new Node(rootNodeId);
    
                    // get the property that holds the node id for the 404 page
                    var property = node.GetProperty("umbracoPageNotFound");
                    if (property != null)
                    {
                        var errorId = property.Value;
                        if (!string.IsNullOrEmpty(errorId))
                        {
                            // if the node id is numeric, then set the redirectId
                            success = int.TryParse(errorId, out this._redirectId);
                        }
                    }
                }
                catch
                {
                    success = false;
                }
    
                return success;
            }
    
            private string GetFullyQualifiedApplicationPath(HttpContext context)
            {
                var appPath = String.Empty;
    
                appPath = string.Format("{0}://{1}{2}{3}",
                                        context.Request.Url.Scheme,
                                        context.Request.Url.Host,
                                        context.Request.Url.Port == 80
                                            ? string.Empty
                                            : ":" + context.Request.Url.Port,
                                        context.Request.ApplicationPath);
    
                if (!appPath.EndsWith("/"))
                {
                    appPath += "/";
                }
    
                return appPath;
            }
        }
    }
    

    And the node from 404handlers.config, which somehow got lost in the comment above:

    <notFound assembly="NAMESPACE" type="MultiSitePageNotFoundHandler" />
    
  • firepol 125 posts 173 karma points
    Jun 06, 2014 @ 13:35
    firepol
    0

    Dawoe, here my 404handlers.config

    <?xml version="1.0" encoding="utf-8" ?>
    <NotFoundHandlers>
      <notFound assembly="umbraco" type="SearchForAlias" />
      <notFound assembly="umbraco" type="SearchForTemplate"/>
      <notFound assembly="umbraco" type="SearchForProfile"/>
      <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />
      <notFound assembly="umbraco" type="handle404"/>
    </NotFoundHandlers>

    Logs: I can see only the UmbracoTraceLog.txt log files... any idea what I have to search to get more info?

    @Bogdan F. I think uComponents 6.0.0 has some bug, I will try to do as you suggested (I was considering coding my own handler... sometimes it's easier than trying to make something work at all costs, just to find out in the end that it has a bug - and that would explain why it's not working...)

  • firepol 125 posts 173 karma points
    Jun 06, 2014 @ 14:00
    firepol
    0

    I can almost 100% confirm that something is wrong either with the instructions on how to setup the uComponents handler, or there is an error in the uComponents assembly or type.

    I just did as Bogdan F. suggested (thanks mate you saved my life and saved me time!): I added the cs file in my project.

    Just to note, it doesn't work for me if I use just "NAMESPACE". I tried infact to use as namespace MultiSitePageNotFoundHandlerCustom.

    I had to modify the namespace to reflect the assembly used in my project...

    So in my case I have a "Helpers" folder and there I have this kind of namespace:

    namespace CustomerX.Corporate.Helpers

    So I just copied/pasted the entire Bogdan F snippet, and replaced "NAMESPACE" with "CustomerX.Corporate.Helpers".

    In my project, the assembly name is "CustomerX.Corporate", so in the end, in the 404handlers.config file I had to put this one:

    <notFound assembly="CustomerX.Corporate" type="Helpers.MultiSitePageNotFoundHandler" />

    Note that in the type I had to add "Helpers" before the class name. Hope this helps somebody.

    I have no time to test on a fresh umbraco 6.2.1 installation + uComponents 6.0.0 but I'm almost sure that something is broken in uCompoents 6.0.0. I guess filing a bug would make sense in this case.

    THANK YOU Bogdan F.! Cheers and enjoy the weekend.

  • Bogdan 250 posts 427 karma points
    Jun 06, 2014 @ 14:18
    Bogdan
    1

    You are welcome! Yeah you are right about the namespace. I'm glad you got it working. And I would also like to thank Lee Kelleher for his amazing work on uComponents, developed on his own free time. He's the one behind the original idea for a handler like this. Thanks Lee!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 23, 2014 @ 22:18
    Lee Kelleher
    0

    @Bogdan - after a plea on an CodePlex issue about this, I've finally had the chance to copy over your patch into the uComponents core (looking at releasing as part of v6.1.0).

    Here's the pending pull request on our GitHub repo.

    Thank you for the patch.

    The only question I have about the code is, why add on the url.Split('/')[0] to the domainName string? Wouldn't this just be an empty string?

    Thanks,
    - Lee

  • Bogdan 250 posts 427 karma points
    Jun 24, 2014 @ 09:47
    Bogdan
    0

    @Lee in my case the domains were set up like http://domain.smth/en-GB, and if a url which should 404 with a page set on the en-GB site would be en-GB/asdf, then url.Split('/')[0] would be en-GB. I did this change quickly, to fit the need of that particular site.

    Thanks!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 24, 2014 @ 09:50
    Lee Kelleher
    0

    Ah ok, I thought the url variable had a leading slash, (I'll double check).

    Cheers,
    - Lee

  • firepol 125 posts 173 karma points
    Jun 24, 2014 @ 14:00
    firepol
    0

    Hi Lee, hi Bogdan,

    after implementing the solution by Bogdan F. I noticed a little problem in my scenario, which I repeat is the following:

    Content
    -SiteA (en) Culture Hostname properly configured Language/Culture: en-US, Domain: http://sitea/en
    -SiteA (de) Culture Hostname properly configured Language/Culture: de-DE, Domain: http://sitea/de
    -SiteB (en) Culture Hostname properly configured Language/Culture: en-US, Domain: http://siteb/en
    -SiteB (de) Culture Hostname properly configured Language/Culture: de-DE, Domain: http://siteb/de

    In all the home nodes I picked the error page for the umbracoPageNotFound property.

    When I browse to some non existing pages for Site A:

    http://sitea/en/nonexisting: I get the English error page I chose for site A
    http://sitea/de/nonexisting: I get the German error page I chose for site A
    http://sitea/foobar: I get the English error page I chose for site A

    when I browse some non existing pages for Site B:

    http://siteb/en/nonexisting: I get the English error page I chose for site B
    http://siteb/de/nonexisting: I get the German error page I chose for site B
    http://siteb/foobar: PROBLEM I get the English error page I chose for site A

    In the last case it's a problem/bug, I get the error page for site A, but I'm browsing site B. Any suggestions to fix this?

  • Bogdan 250 posts 427 karma points
    Jun 24, 2014 @ 14:44
    Bogdan
    0

    Hi firepol,

    not a very elegant solution, but after

    var rootNodeId = Domain.GetRootFromDomain(domainName);
    

    you can add

    if (rootNodeId <= 0) rootNodeId = Domain.GetRootFromDomain(GetFullyQualifiedApplicationPath(HttpContext.Current));
    

    Regards,

    Bogdan

  • firepol 125 posts 173 karma points
    Jun 24, 2014 @ 15:39
    firepol
    0

    Hi Bogdan, I tried your code, that didn't fix the problem. Still being redirected to the english error page for site A...

  • Bogdan 250 posts 427 karma points
    Jun 24, 2014 @ 15:49
    Bogdan
    0

    You are right, giving it a second look it cannot work like that, because there are no pages with the domain exactly as http://siteb. I'll think about it and get back to you.

  • Bogdan 250 posts 427 karma points
    Jun 24, 2014 @ 16:08
    Bogdan
    1

    Ok, please try this:

    // get the current domain name
    var domainName = GetFullyQualifiedApplicationPath(HttpContext.Current);
    
    // get the root node id of the domain
    var rootNodeId = Domain.GetRootFromDomain(domainName  + url.Split('/')[0]);
    
    if (rootNodeId <= 0)
    {
        var closestDomain = Domain.GetDomains().Where(d => d.Name.StartsWith(domainName)).FirstOrDefault();
    
        if (closestDomain != null)
        {
            rootNodeId = Domain.GetRootFromDomain(closestDomain.Name);
        }
    }
    
  • firepol 125 posts 173 karma points
    Jun 24, 2014 @ 17:10
    firepol
    0

    @Bogdan F.: This worked! Thank you! Very much appreciated!

    @Lee: maybe you can add also this fix in git?

    Thanks again! Looking forward for uComponents 6.1.0 ;)

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Mar 18, 2015 @ 11:56
    Simon Dingley
    0

    I've had similar problems in a v6 site recently where this was previously working in v4 but now doesn't. I have pulled the source for uComponents then made this change which worked fine for me and saves messing around with the strings trying to pull out what you need:

        public bool Execute(string url)
        {
            HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.NotFound;
    
            var success = false;
    
            // get the current domain name
            var fqaPath = GetFullyQualifiedApplicationPath(HttpContext.Current);
    
            var currentUri = new Uri(fqaPath);
    
            // get the root node id of the domain
            var rootNodeId = Domain.GetRootFromDomain(currentUri.Authority);
    
            try
            {
                // if a valid nodeId isn't returned, then get the top-most content node.
                if (rootNodeId <= 0)
                    rootNodeId = uQuery.GetRootNode().Children[0].Id;
    
                // get the node
                var node = new Node(rootNodeId);
    
                // get the property that holds the node id for the 404 page
                var property = node.GetProperty("umbracoPageNotFound");
                if (property != null)
                {
                    var errorId = property.Value;
                    if (!string.IsNullOrEmpty(errorId))
                    {
                        // if the node id is numeric, then set the redirectId
                        success = int.TryParse(errorId, out this._redirectId);
                    }
                }
            }
            catch
            {
                success = false;
            }
    
            return success;
        }
    

    currentUri.Authority is the key here that worked for me.

Please Sign in or register to post replies

Write your reply to:

Draft