Copied to clipboard

Flag this post as spam?

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


  • Delete me 45 posts 66 karma points
    Oct 18, 2009 @ 20:02
    Delete me
    0

    Hello

    I want to do the following in my template, where the page is called with /page.aspx?pass=123:

    If pass=123, do something

    else: access denied

    How to do this? I guess I need some c# code?

     

    Thanks a lot

    /Mathias

  • Sebastiaan Janssen 5045 posts 15478 karma points MVP admin hq
    Oct 18, 2009 @ 20:59
    Sebastiaan Janssen
    1

    You could actually do it simply in XSLT by doing something like this:

     

    <xsl:choose>
     <xsl:when test="umbraco.library:RequestQueryString('pass') = 123">
      Do something
     </xsl:when>
     <xsl:otherwise>
      Access denied
     </xsl:otherwise>
    </xsl:choose>
  • Sebastiaan Janssen 5045 posts 15478 karma points MVP admin hq
    Oct 18, 2009 @ 21:11
    Sebastiaan Janssen
    1

    By the way, this is obviously not a secure way of controlling access to certain content. I would advise you to actually use the membership provider, have a look at this blog post: http://www.mortenbock.dk/blog/2009/04/01/setting-up-membership-in-umbraco.aspx

  • Delete me 45 posts 66 karma points
    Oct 19, 2009 @ 15:10
    Delete me
    0

    Thanks for your reply!

    I know its not safe this way, but the meaning is just to make a page easy avaible only from a complicated link (sent by email) and not by google, etc.
    I also know its easy to do in XSLT, but as I already have some C# code and .NET controls in my template, I think it would be difficult to move it from the template to XSLT.

  • Delete me 45 posts 66 karma points
    Oct 19, 2009 @ 15:55
    Delete me
    0

    I solved it rather simply, but it works, and as long the redirect is server-side, I'm happy :)

    private void Page_Load(object sender, System.EventArgs e)
    {
    string pass = Request.QueryString["pass"];
    if (passCode != "h78h3i8chjkh78fhjn3987njknjf9h") {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","/");
    }
    }
Please Sign in or register to post replies

Write your reply to:

Draft