Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7015711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:41:15+00:00 2026-05-27T22:41:15+00:00

I am using the method described in the following LINK and I am using

  • 0

I am using the method described in the following LINK and I am using the following code to encrypt:

'Page1.aspx    
Protected Sub butEncrypt_Click(sender As Object, e As EventArgs) Handles butEncrypt.Click
    Dim QueryString As String = "type=Int&pk=" & _primaryKey
    QueryString = Tools.encryptQueryString(QueryString)
    Response.Redirect(/SearchResults.aspx?Val=" & QueryString)
End Sub

and then finally de-encrypt:

        'SearchResults.aspx
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If (Not IsPostBack) Then
         If Not String.IsNullOrEmpty(HttpContext.Current.Request(CIAppGlobals.GlobalVar.Val)) Then
            Dim qs As String = Request.QueryString(CIAppGlobals.GlobalVar.Val)
            qs = Tools.decryptQueryString(qs)

            Dim Values As String() = qs.Split(CChar("&"))

            _imageType = String.Empty
            _primaryKey = 0

            For Each value As String In Values
               Dim data As String() = value.Split(CChar("="))

               Select Case data(0).ToUpper
                  Case "TYPE"
                     _imageType = data(1)
                  Case "PK"
                     _primaryKey = CInt(data(1))
               End Select
            Next
            Else
               _imageType = HttpContext.Current.Request("type")
               _primaryKey = CInt(HttpContext.Current.Request("pk"))
         End If
    End If
   End Sub

My question is should I being using a different method to extract the decoded query string values other than what I am doing? Thanks in advance for your constructive responses.

Solution

After looking at Darin’s response I have decided to incorporate it into my project, here is my updated code:

'Page1.aspx    
Protected Sub butEncrypt_Click(sender As Object, e As EventArgs) Handles butEncrypt.Click
  Dim query = HttpUtility.ParseQueryString(String.Empty)
  query("type") = "Int"
  query("pk") = CStr(_primaryKey)

  Dim QueryString As String = Tools.encryptQueryString(query.ToString())
  Response.Redirect(/SearchResults.aspx?Val=" & QueryString)
End Sub

I still want to encrypt the query string because I want to prevent users from changing the Query String Values manually

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:41:16+00:00Added an answer on May 27, 2026 at 10:41 pm

    You are incorrectly building the query string in the first place. You are using string concatenations and not properly encoding them. What if _primaryKey contains a & or = characters? You could use the ParseQueryString method to properly build a query string:

    Dim query = HttpUtility.ParseQueryString(String.Empty)
    query("type") = "Int"
    query("pk") = _primaryKey
    Dim queryString = query.ToString()
    

    The same method could be used for parsing the decoded query string:

    Dim values = HttpUtility.ParseQueryString(qs)
    Dim type = query("type")
    Dim primaryKey = query("pk")
    ' work with the type and primaryKey values
    

    Never use string concatenations and splitting when dealing with urls. Always use the right tool for the right job.

    That’s as far as creating/parsing query strings is concerned. As far as encrypting/decryption the values is concerned, you haven’t shown/told us anything about the Tools class that you are using so I cannot provide you with any constructive comments about it.

    You know that the best encryption is to never send the actual value to the client. So you could store it in some backend storage on the server and then use an unique id in the url. This id could be used on the target page to fetch the original value. This way you don’t need to be encrypting/decrypting anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the method described by Josh in this question to add a toolbar
I've done scaffolding using the method described here http://wiki.rubyonrails.org/rails/pages/ScaffoldGenerator However, I want to know
I got the Date value from the method from the following code DATE dDate;
Following this link I tried sending a XML file to my web service using
The following link describes how to handle module initialization and destruction in Guice using
I am trying to distribute my Enterprise Application using the method described in the
I am following authentication method described at http://blogs.msdn.com/b/astoriateam/archive/2010/07/21/odata-and-authentication-part-6-custom-basic-authentication.aspx I am able to consume service
After following successfully the method to set multiple LAUNCHER activities (as described in https://stackoverflow.com/a/3270783/978329
Firstly, I'm using the GetHashCode algorithm described, here . Now, picture the following (contrived)
When programming against a fluent API or just using method-chaining, I've seen the style

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.