Copied to clipboard

Flag this post as spam?

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


  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 17, 2010 @ 14:36
    Peter Duncanson
    0

    Clean redirect from within my XSLT?

    Simply problem, I have a product view page which you are meant to get to via a url like this:

    /product-indepth.aspx?id=1234

    I use urlrewriting to make this all pretty.

    I simply want to redirect the user to the homepage if no id is passed through, ie they are trying to hit the page directly.

    Can't seem to find a clean, simple, easy way. Am I missing a trick or do I need to create one? :)

    Cheers

    Pete

  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 17, 2010 @ 14:38
    Peter Duncanson
    0

    Oh I know how to get the ID out using umbraco.library:Request( 'id' ) and can build the if statement to check its there, its the redirecting that I'm struggling with. I want something like:

    <xsl:if test="$id = ''">
        <xsl:value-of select="some.library:RedirectTo('/homepage.aspx')" />
    </xsl:if>

    Any ideas?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 17, 2010 @ 14:46
    Sebastiaan Janssen
    0

    There is nothing available that I know of but you could make a simple xslt extensions that does something like:

    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","/");

    Not much more needed than that right? :-)

  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 17, 2010 @ 14:48
    Peter Duncanson
    0

    That would do it, seems a bit over kill to have to build an extension for it. But I suppose I need to start on that funky "helpers" extention so this might be the first method in there.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 17, 2010 @ 14:54
    Chriztian Steinmeier
    1

    Hi Peter,

    If you don't want/need a 301 redirect, but rather a 302, you could spew some crude JavaScript into the page, to preform the redirect...

    /Chriztian 

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 17, 2010 @ 14:55
    Sebastiaan Janssen
    0

    Or, for now, I think you could get away with some inline C# and not have to create a whole VS project (check XSLTSearch to see how Doug has done it).

Please Sign in or register to post replies

Write your reply to:

Draft