If you're comfortable with Visual Studio, feel free to download the uComponents source-code and extract the "MultiSitePageNotFoundHandler.cs" ... then compile that in your own project. (or you might be able to drop it into your App_Code folder - but I've never tried that!)
Otherwise, just install uComponents as is - there's no requirement to use any of the other data-types/components, etc.
Installed it on a localhost page. I added the alias umbracoPageNotFound to homepages and selected my 404 pages, but i still get the old regular 404 page.
Is this step mandatory?
To manually enable this functionality, add the following setting as the
penultimate of the "NotFoundHandlers" section in
/config/404handlers.config, (e.g. the one before the "handle404" entry):
I have a hostname for both my pages (different ones of course) - and both homepage nodes have the contentpicker type assigned - but still the regular 404 page pops up
I don't know if the localhost placement is doing something to ruin the hostheader setup?
I'm using webmatrix to launch the site locally, but then i'm not really accessing the two domains on seperate domains. I can acess all the pages from the two domains from http://localhost:11563/<nodename here>.aspx
Ah ok, this explains it. The code for the NotFoundHandler is trying to look for the domain name based on the one you are currently viewing (from the Request.ServerVariables["SERVER_NAME"]). So if you are using "localhost", but the root node's hostname is something else, then it wont find the 404 page.
If you wanted to test this, you could manually edit your "C:\Windows\system32\drivers\etc\hosts" file?
Lol, i get an old Runway test site, i guess it's the default webpage in the IIS locally. I'm not sure how Webmatrix and IIS works together. I can't seem to point the domains to the port that Webmatrix generates.
Its going to be a bit of a fudge, but start-up the website via WebMatrix, then swap the "localhost" part with "www.domain1.com" - making sure to keep the port numbers on the end.
In the case I want to add the code MultiSitePageNotFoundHandler.cs to App_Code, how will I need so set 404handlers.config? I think that the assembly attribute is mandatory but I'm not sure what to put there because I don't have a .dll name. Ref.
I took a look at the code in the core that does the NotFoundHandler checks - it looks for the assembly (DLL) in the /bin folder ... so if it's not there, then it can't load it!
In a nutshell, NotFoundHandlers need to be compiled to an assembly.
4.7.0 and multiple 404 pages
Hi there
in 4.5.1 there was 404 support for each language in order to have seperate 404 pages.
I have two sites in the same umbraco that uses the same language that can't use the same 404 page. Is this possible to set up in 4.7.1?
A thread on this forum suggest to make your own handler to process the different 404 requests:
http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler
Should i just insert this handler code directly into the umbracoSettings.config instead of the current 404 snippet?
Hi Martin,
Take a look at the MultiSitePageNotFoundHandler in uComponents, it might suit your needs better?
Cheers, Lee.
Hi Lee
This component can do all sorts of fancy stuff i presume, how easy is it to just work the the 404 handler?
Hi Martin,
If you're comfortable with Visual Studio, feel free to download the uComponents source-code and extract the "MultiSitePageNotFoundHandler.cs" ... then compile that in your own project. (or you might be able to drop it into your App_Code folder - but I've never tried that!)
Otherwise, just install uComponents as is - there's no requirement to use any of the other data-types/components, etc.
Cheers, Lee.
Hi Lee
Installed it on a localhost page. I added the alias umbracoPageNotFound to homepages and selected my 404 pages, but i still get the old regular 404 page.
Is this step mandatory?
To manually enable this functionality, add the following setting as the penultimate of the "NotFoundHandlers" section in /config/404handlers.config, (e.g. the one before the "handle404" entry):
Nevermind, it's already inserted... hmm :/ ?
Hi Martin,
Yes it's mandatory - adding that line to the 404handlers.config is key to it working.
Cheers, Lee.
Here's what my 404handlers look like atm:
I have a hostname for both my pages (different ones of course) - and both homepage nodes have the contentpicker type assigned - but still the regular 404 page pops up
Just checking... is your content-picker alias definitely "umbracoPageNotFound" (case-sensitive)?
I've ran a quick test on one of my dev sites here. Set the hostname/language of the homepage node, assigned a 404 page - and it worked fine.
Cheers, Lee.
...forgot to menion, your 404handler.config is correct!
I should think so, i copied it from the codeplex guide:
Maybe my redirect function destroys the functionality?
Interesting... I'll give it a quick test here!
Nope - mine works with "umbracoRedirect" set to a different node too!
Hmmm... curious what the problem is now!
I don't know if the localhost placement is doing something to ruin the hostheader setup?
I'm using webmatrix to launch the site locally, but then i'm not really accessing the two domains on seperate domains. I can acess all the pages from the two domains from http://localhost:11563/<nodename here>.aspx
Ah ok, this explains it. The code for the NotFoundHandler is trying to look for the domain name based on the one you are currently viewing (from the Request.ServerVariables["SERVER_NAME"]). So if you are using "localhost", but the root node's hostname is something else, then it wont find the 404 page.
If you wanted to test this, you could manually edit your "C:\Windows\system32\drivers\etc\hosts" file?
Cheers, Lee.
Sure, should i just point www.domain1.com and www.domain2.com to 127.0.0.1 ?
Yeah, then hopefully it should work! :-)
Lol, i get an old Runway test site, i guess it's the default webpage in the IIS locally. I'm not sure how Webmatrix and IIS works together. I can't seem to point the domains to the port that Webmatrix generates.
I'll guess i'll take your word for it :-)
Its going to be a bit of a fudge, but start-up the website via WebMatrix, then swap the "localhost" part with "www.domain1.com" - making sure to keep the port numbers on the end.
Cheers, Lee
It's not really working for me, regardless of the values in the hostfile it keeps accessing the online site, not local host.
I'm pretty sure it'll work when i get it online at the new webserver :-)
Okay. Did you try setting one of the hostname's to "localhost"?
Now, that worked! Only for the one domain ofcourse but i got the right 404 page!
Woo hoo! Glad that we got there in the end!
Cheers, Lee.
Woo hoo! right back at you.
Lot's of karme your way for your kind help, much appreciated! MVP for sure! :-)
He Lee
In the case I want to add the code MultiSitePageNotFoundHandler.cs to App_Code, how will I need so set 404handlers.config? I think that the assembly attribute is mandatory but I'm not sure what to put there because I don't have a .dll name. Ref.
Thank you
Jorge
Hi Jorge,
I haven't tried that before, so not sure how the App_Code assembly could be referenced.
Have you tried any ideas yet? I'm thinking something like this...
If that doesn't work - I'm not sure how to achieve it. I'd suggest compiling it into it's own DLL... or use uComponents? ;-)
Cheers, Lee.
Hi Lee
Thanks for your quick response. I've tried the following but doesn't work :( It gives a null pointer exception.
I would like to have all code in App_Code.
Thanks!
Jorge
Hi Jorge,
I took a look at the code in the core that does the NotFoundHandler checks - it looks for the assembly (DLL) in the /bin folder ... so if it's not there, then it can't load it!
In a nutshell, NotFoundHandlers need to be compiled to an assembly.
Cheers, Lee.
Hi Lee
Thank you for your response!
Cheers
Jorge
is working on a reply...