how to decode a query string in ASP.NET 2.0


I have the followin code in a .ascx.cs file:

string myQueryString = Request.QueryString.ToString();

Please, can some one show me how to decode the querystring before I assign it to myQueryString variable?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

anyoneisConnect With a Mentor Commented:
I believe this will do the trick for you:

        string [] parmArray = Request.QueryString.ToString().Split('&');
        for (int i = 0; i < parmArray.Length; i++)
            parmArray[i] = HttpUtility.UrlDecode(parmArray[i]);

What do you mean by"decode the query string" What is it that you want to do with it. Why not just use the QueryString collection?

string fooParm = Request.QueryString["foo"]
string firstParm = Request.QueryString[1]

vielkacarolina1239Author Commented:
I am assigning the query string to a variable. The variable contains + for the space and ....

I will like to decode the encoded characters in the query string when I assign it to the variable, myQueryString. I am parsing myQueryString variable my self. I am doing this becuase Request.QueryString["keyName"] cannot have duplicate entries and my query string does have duplicated entries, keys that are repeated.

Please, show me how to decode the query string and assign the decoded value to myQueryString.
vielkacarolina1239Author Commented:
When one uses Request.QueryString.AllKeys[x], this piece of code automatically decodes the current key. But the object Request.QueryString.ToString(), has the encoded string.
All Courses

From novice to tech pro — start learning today.