Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jun 18, 2010 @ 10:11
    Sebastiaan Janssen
    0

    404 to a specific URL (not a node)

    I'm looking for some input on this subject:

    I have an umbraco install that contains several different sites. I wanted to turn on the default Umbraco 404 handler, but I need to enter a content ID for that. I don't want to do that, because that would make people go out of the current site that they're in and into a different site (or no site at all).

    The second problem I have is that my site has a stretchable layout, it will always be 100% width and height. I have some pieces of content showing up in a lightbox, like the contact and "about us" page. I'd like to show the 404 error in a lightbox like that.

    So what I'd need is: when a 404 error is triggered, I want it to show up in the homepage of the site that the user is in, with the lightbox visible (this is already possible by going to the url like so: http://site.com/?popup=/pages/404.aspx).

    Can this be done? I think it could be done by doing a url rewrite, but I am unsure of how to do this in a multisite set-up.

  • Petr Snobelt 923 posts 1535 karma points
    Jun 18, 2010 @ 11:23
    Petr Snobelt
    0

    I think this functionality is allready build in IIS, but I can't find out how to completly disable umbraco 404 handling.

    So, you can create your custom 404 handler - http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler

    Petr

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jun 18, 2010 @ 13:58
    Sebastiaan Janssen
    0

    Great tip! I just implemented the 404 handler from the wiki and changed the Execute method to the below code, it's not pretty but it does the job.

            public bool Execute(string url)
            {
                var server = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();
                var redirectUrl = string.Format("http://{0}/?popup=http://{0}/?altTemplate=NotFound", server);
    
                HttpContext.Current.Response.Status = "404 Not Found";
                HttpContext.Current.Response.Redirect(redirectUrl);
    
                return true;
            }
    
Please Sign in or register to post replies

Write your reply to:

Draft