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).
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)
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 :
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.
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.
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:
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:
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
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:
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! ;)
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:
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:
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...)
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:
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.
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!
@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).
@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.
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?
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.
// 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);
}
}
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.
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.
Hi,
Do you have access to the config/umbracoSettings.config file?
Yes. I have access for all project files(by permissions and physically).
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
I can't use that because I have two sites with equal culture
Hi Max,
Do nodes "2) Dutch" and "3) French" have a domain/hostname associated with them?
Cheers, Lee.
Home pages have url like:
2) domain/nl/
3) domain/fr/
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 :
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
Sébastien, I'm already using this solution. But it doesn't work on site with language selection page.
thx
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
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
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
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.
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:
Is this correct Lee?
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.
Cheers, Lee.
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:
This setting should be set to PassThrough to allow custom errors. While were in web.config, also look for:
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
Lee's solution above worked for me in my multi-site installation.
Has anyone had an issue where this works until you change a hostname then just stops?
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
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.
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 theweb.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
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:
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:
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:
If I add in the web.config, in <system.webServer>, as mentioned by Lee:
I get this error:
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:
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...
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:
I see in the documentation that my notFound setting should be the correct one :
http://ucomponents.codeplex.com/wikipage?title=MultiSitePageNotFoundHandler&referringTitle=Documentation
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:
still not working.
Are your sites located under the root of the content tree ?
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
Can you post your entire 404handlers.config
And also can you check your log for info when you try to get a 404 page. There is sometimes usefull information in there.
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
Aha, I found it!
And the node from 404handlers.config, which somehow got lost in the comment above:
Dawoe, here my 404handlers.config
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...)
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:
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.
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!
@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 thedomainName
string? Wouldn't this just be an empty string?Thanks,
- Lee
@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!
Ah ok, I thought the
url
variable had a leading slash, (I'll double check).Cheers,
- Lee
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?
Hi firepol,
not a very elegant solution, but after
you can add
Regards,
Bogdan
Hi Bogdan, I tried your code, that didn't fix the problem. Still being redirected to the english error page for site A...
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.
Ok, please try this:
@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 ;)
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:
currentUri.Authority
is the key here that worked for me.is working on a reply...