Copied to clipboard

Flag this post as spam?

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


  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:03
    MartinB
    0

    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?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:06
    Lee Kelleher
    1

    Hi Martin,

    Take a look at the MultiSitePageNotFoundHandler in uComponents, it might suit your needs better?

    Cheers, Lee.

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:15
    MartinB
    0

    Hi Lee

    This component can do all sorts of fancy stuff i presume, how easy is it to just work the the 404 handler?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:20
    Lee Kelleher
    1

    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.

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:33
    MartinB
    0

    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):

    <notFound assembly="uComponents.Core" type="NotFoundHandlers.MultiSitePageNotFoundHandler" />
  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:35
    MartinB
    0

    Nevermind, it's already inserted... hmm :/ ?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:35
    Lee Kelleher
    1

    Hi Martin,

    Yes it's mandatory - adding that line to the 404handlers.config is key to it working.

    Cheers, Lee.

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:39
    MartinB
    0

    Here's what my 404handlers look like atm:

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

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:45
    Lee Kelleher
    1

    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.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:46
    Lee Kelleher
    1

    ...forgot to menion, your 404handler.config is correct!

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:48
    MartinB
    1

    I should think so, i copied it from the codeplex guide:

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:49
    MartinB
    0

    Maybe my redirect function destroys the functionality?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:50
    Lee Kelleher
    1

    Interesting... I'll give it a quick test here!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:53
    Lee Kelleher
    1

    Nope - mine works with "umbracoRedirect" set to a different node too!

    Hmmm... curious what the problem is now!

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 21:53
    MartinB
    0

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 21:57
    Lee Kelleher
    1

    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.

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 22:00
    MartinB
    0

    Sure, should i just point www.domain1.com and www.domain2.com to 127.0.0.1 ?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 22:02
    Lee Kelleher
    1

    Yeah, then hopefully it should work! :-)

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 22:05
    MartinB
    0

    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 :-)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 22:06
    Lee Kelleher
    1

    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

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 22:13
    MartinB
    0

    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 :-)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 22:18
    Lee Kelleher
    1

    Okay. Did you try setting one of the hostname's to "localhost"?

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 22:31
    MartinB
    0

    Now, that worked! Only for the one domain ofcourse but i got the right 404 page!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 21, 2011 @ 22:32
    Lee Kelleher
    1

    Woo hoo! Glad that we got there in the end!

    Cheers, Lee.

  • MartinB 411 posts 512 karma points
    Mar 21, 2011 @ 22:34
    MartinB
    1

    Woo hoo! right back at you.

    Lot's of karme your way for your kind help, much appreciated! MVP for sure! :-)

  • Jorge 15 posts 36 karma points
    Apr 29, 2011 @ 11:31
    Jorge
    0

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Apr 29, 2011 @ 11:46
    Lee Kelleher
    0

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

    <notFound assembly="App_Code" type="MultiSitePageNotFoundHandler" />

    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.

  • Jorge 15 posts 36 karma points
    Apr 29, 2011 @ 12:52
    Jorge
    0

    Hi Lee

    Thanks for your quick response. I've tried the following but doesn't work :( It gives a null pointer exception.

    <notfound assembly="App_Code" namespace="esmo.alphabetfolder" type="NotAlphabetFolderInUrlHandler" />       

    I would like to have all code in App_Code.

    Thanks!

    Jorge

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Apr 30, 2011 @ 15:23
    Lee Kelleher
    0

    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.

  • Jorge 15 posts 36 karma points
    May 02, 2011 @ 08:36
    Jorge
    0

    Hi Lee

    Thank you for your response!

    Cheers

    Jorge

Please Sign in or register to post replies

Write your reply to:

Draft