Copied to clipboard

Flag this post as spam?

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


  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 25, 2013 @ 16:22
    Matt Brailsford
    0

    How can I get altTemplate to work when redirected from a NotFoundHandler

    Hi,

    I'm creating a site (Umbraco 4.11.1) which uses uCommerce and am using a notfoundhandler to allow urls such as

    mydomain.com/category-name
    mydomain.com/product-name

    Note, I can't use rewriting here as these requests need to route to seperate physical pages, so there is no rule that could handle it (ie there is no unique "category" / "product" identifier).

    So when the handler is hit, it tries to find a category or product whith a slug that matches and if it does, it redirects to the relevant node to handle it. This all works fine. The problem comes when I want to use an altTemplate.

    I use alt template so that I can load parts of a page via ajax ala http://24days.in/umbraco/2012/ajax-paging-using-alttemplates/

    The problem then is that the altTemplate isn't honored after the redirect takes place. Anyone got any sugestions on how I could force the template change? Can I set it via a route jacked controller (I have one already to set uCommerces context)?

    Cheers

    Matt

  • Stephen 767 posts 2273 karma points c-trib
    Jan 25, 2013 @ 18:46
    Stephen
    0

    Are you using Mvc templates, or WebForms?

    Couple of things:

    There's a global issue in 4.11 with NotFoundHandlers. They run too late in the pipeline. If you look at you HTTP request you'll see that it's a 404 even though your NotFoundHandler returned a document. I'm currently experimenting with a fix on 6.1 that I should backport to 4.11.4 next week.

    The altTemplate is honored _only_ if you display the expected document. Because the NotFoundHandlers run when we _think_ we are not able to display the expected document, the altTemplate is not honored anymore. But... if the NotFoundHandlers run at the right place (xcept for the builtin 404) then we'll believe it's the expected document, and altTemplate will apply.

    So... should be able to do it soo.

    I'm trying to think of a workaround in the meantime... but it depends on whether you're Mvc or WebForms.

    Stephan

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 25, 2013 @ 18:56
    Matt Brailsford
    0

    Hi Stephan.

    The project is MVC so if you have some workarounds for that it would be greatly appreciated.

    Many thanks

    Matt

  • Stephen 767 posts 2273 karma points c-trib
    Jan 29, 2013 @ 09:59
    Stephen
    0

    Sorry Matt I know there's a way but can't remember it, and been busy these days... Again, sorry.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 29, 2013 @ 10:01
    Matt Brailsford
    0

    Hey Stephen,

    No worries, I get my AJAX based calls to use different urls for the time being which contain specific route details so no need to go via the 404 handler for this. Would love to hear a better way though if you do remember.

    Many thanks

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft