Copied to clipboard

Flag this post as spam?

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


  • Bent Holz 100 posts 273 karma points
    Sep 21, 2013 @ 13:56
    Bent Holz
    0

    Request.querystring and redirect

    On my site I have a page with a paypal-button. When you press this button, you are taken to the paypal website for payment and after you enter your details and actually pay, you are then taken back to my site.

    When returning from paypal I've included a variable called let say "pay" so the return url looks like this:

    http://www.mysite.com/paywentthrough.apsx?pay=1

    On the landing page I would like the page to check for this variable, and if this variable is not found, the page should redirect the user to another page.

    In old school asp you would simply ad something like:

    <% if not request.querystring("pay") = 1 then response.redirect("http://www.getthehellout.com") %>

    But since I'm not at all into .net I have no idea on how to do this?  do I set up a macro on the landingpage with some .net code and how would that code look like?

    Any help is appreciated...

    Crawn

  • Charles Afford 1163 posts 1709 karma points
    Sep 21, 2013 @ 22:30
    Charles Afford
    0

    Hi, what languages are you using?  webforms/xslt or razor/MVC?   Having a query string of pay=1, feels really insecure.  I would recommend looking at:

    http://our.umbraco.org/wiki/umbraco-help/content/editcontent/rich-text-editor/macros

    if you are using xslt then you will probably need to use an extension function so you cannot use complied code.

    http://our.umbraco.org/wiki/reference/xslt/extend-your-xslt-with-custom-functions

    Charlie :)

  • Kasper Dyrvig 246 posts 379 karma points
    Sep 27, 2013 @ 00:01
    Kasper Dyrvig
    100

    If you just need a quick solution, here is how I sometimes have done it (and since we are in the xslt forum I stick to that):

    1. Create an XSLT file with macro in the developer section.
    2. Put in the XSLT logic along with some javascript to do the redirect...
    <xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/>
    <xsl:if test="$q != '1'">
    <script type="text/javascript">window.location = "/";</script>
    </xsl:if>

    That's really it - for a quick and dirty solution. I agree with Charles that this very secure. But maybe you aren't looking for that...?

    If you have any further questions, please post them!

  • Bent Holz 100 posts 273 karma points
    Sep 27, 2013 @ 09:02
    Bent Holz
    0

    Thx for your time guys...

    This is what i got from this:

    I created a macro and threw in a code similar to the one you wrote Kasper, and threw the macro into my page template and it worked like a charm!

    The macro:

    <xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/>
    <xsl:if test="$q != '1'">
      <script type="text/javascript">window.location = "http://www.google.com/";</script>
    </xsl:if>

    The code above asks "if you don't have the pay value of 1, then im sending you to google.com"

    But for me to understand a little from this... where in the xsl does the code "ask" if you don't have this value then go away? Is it the "!"?

    Regarding the 1 value I know this is higly insecure, and I just used it to make the example as simple as possible.  :)

    Good karma and good coffee to the both of you!

    Thx!

    Crawn

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 27, 2013 @ 09:24
    Dennis Aaen
    0

    Hi Crawn,

    Yes you are absolutely on track, the ! means not, so when it´s != means that the variable q is not equal to 1.

    And if you want to check if the q varaible is equal to 1 then you of couse just use the = 1

    I know it's a simple explanation

    <!-- Here we are making a check of the q is not equal to 1 -->
    <
    xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/>
    <xsl:if test="$q != '1'">
      <script type="text/javascript">window.location = "http://www.google.com/";</script>
    </xsl:if>
    <!-- Here we are making a check of the q is equal to 1 -->
    <
    xsl:variable name="q" select="umbraco.library:RequestQueryString('pay')"/>
    <xsl:if test="$q = '1'">
      <script type="text/javascript">window.location = "http://www.google.com/";</script>
    </xsl:if>

    /Dennis

     

     

  • Bent Holz 100 posts 273 karma points
    Sep 27, 2013 @ 10:05
    Bent Holz
    0

    Thx Dennis...

    You can have a cup aswell ;)

    Crawn

Please Sign in or register to post replies

Write your reply to:

Draft