How to hide the querystring parameters in a javascript redirect

Last post 07-03-2009 6:58 AM by kthumm. 3 replies.

Sort Posts:

  • How to hide the querystring parameters in a javascript redirect

    07-01-2009, 10:55 AM
    • Member
      1 point Member
    • kthumm
    • Member since 05-19-2008, 6:40 AM
    • Posts 7

    Hi, I'm using  javascript to redirect the user to our error page. I'm doing it this way as I'm trapping errors in our AJAX panel, so have no option but to use javascript.

    So my function has

    window.location.href="../error.aspx?param=value";

    This works fine except that the user can see (and potentially edit) the values in the querystring. Is there any way of hiding the values whilst still passing them for the error page to pick up.

    Thanks

     

  • Re: How to hide the querystring parameters in a javascript redirect

    07-01-2009, 1:13 PM
    • All-Star
      77,577 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,465
    • TrustedFriends-MVPs
  • Re: How to hide the querystring parameters in a javascript redirect

    07-01-2009, 1:37 PM
    Answer
    • Participant
      1,129 point Participant
    • jamezw
    • Member since 07-20-2003, 10:52 PM
    • Tampa Bay
    • Posts 179

    You could dynamically post to the error page as well. Refer to this link: http://mentaljetsam.wordpress.com/2008/06/02/using-javascript-to-post-data-between-pages/

    Then you can move to the error page with a javascript call like so:

    postwith('error.aspx',{param:'foo'});

    Then you could read in this posted variable from the error page:
    string param = Request.Form["param"];
    

    Mind you, people could still POST to your error page using this method but it would not be as visible/obvious as using the query string parameter.

    -=JW=-
  • Re: How to hide the querystring parameters in a javascript redirect

    07-03-2009, 6:58 AM
    • Member
      1 point Member
    • kthumm
    • Member since 05-19-2008, 6:40 AM
    • Posts 7

     Thank you both for your replies.

    I went with jamezw's solution as I wanted to keep it all in the javascript function, and it worked a treat.

    I then used VB on the error page (i.e. Me.Request.Form.item("param") ) to pick up the passed in parameters, rather than javascript as I needed to process the parameters as part of an existing VB process. That worked a treat too.

    So I now have a much neater and more secure redirect happening. Thankyou very much !!!

Page 1 of 1 (4 items)