How to encode QueryString in ASP.NET 2.0 and decode in JSP?

Posted on 2006-05-03
Last Modified: 2008-01-09
After migrating to a ASP.NET 2.0 application I have to add a link to a legacy application written in Java.  Basically my app will use redirect to a login page with http://localsite/login.jsp?name=John&pwd=Hello.  I do not want to display credentials as clear text, what should be done in order to encrypt querystring in ASP.NET 2.0 and then deciphered on JSP page?
Question by:TornadoV
    LVL 42

    Expert Comment

    Querystring is going to be visible whether you encode it or not so I'm not sure what you're asking?  You can encrypt 'John' to be 'H&y4Fv_9' but that isn't going to stop someone from copying 'H&y4Fv_9' and pasting it into a URL at a later date...

    If you want to have credentials hidden then don't put them in the querystring!
    LVL 14

    Accepted Solution

    1. Construct a string containing a user name and password.
         Dim str as string="user=John&pwd=Hello"

    2. Encrypt this string with some string encription.

    3. Pass the resulting string to java app
         Response.redirect("http://localsite/login.jsp?user=" & MyEcryptedString)

    4. Decrypt that string at java app side, parse it into user name and password and check if credentials are valid...
    LVL 11

    Author Comment

    Frodoman, I'm sorry for not being clear, it's an intranet app, I simply did not want to display user's credentials as clear text in their address bar.  I was looking for Convert.ToBase64String() equivalent in Java since I'm not proficient in it.  

    I gave all points to Ramuncikas simply because I've implemented his suggestion even without looking at it first.

    Thanks for your help guys!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now