QueryString

G

Guest

I am a newbie in .NET. I am trying to collect the query string and paste it
to the new url. The problem is I am not sure with the particular names of the
query string elements are. How can I iterate through the QueryString
collection and copy the values to the URL?
Please help me with some code examples.

HS
 
G

Guest

I tried that but it returns something that looks like this:

"/bscore/topmovers/_hpc/_1/016305.htmNRMODE=Published&NRORIGINALURL=%2fbscore%2ftopmovers%2fdefault.htm&NRNODEGUID=%7b428F5151-FE96-49B9-9178-8F1A9D59A316%7d&NRCACHEHINT=ModifyLoggedIn"

I am afraid this is not the right URL. I am not much of an expert, but the
..htm is repeated over several times there. I don't fully understand the %
signs neither, but I guess that relates to the path in my pc.

I tried this:

// Load NameValueCollection object.
NameValueCollection coll = Request.QueryString;

// Get names of all keys into a string array.
string[] keyArray = coll.AllKeys;

for (int i = 0; i < keyArray.Length; i++)
{
redirectTo += keyArray + "=";
string[] valueArray = coll.GetValues(keyArray);

for (int j = 0; j < valueArray.Length; j++)
{
redirectTo += valueArray[j];
}
}

But the result is pretty much the same.
 
W

William F. Robertson, Jr.

The % are url encoded values.

What did your original url look like?

http://server.com/bob.aspx?/bscore/topmovers/_hpc/ ....ModifyLoggedIn.

If so, then that is correct, it is isn't, then there is something deeper
here.

Your loop looks pretty good, but when you are using the last for loop
stepping through your values, you should have

redirectTo += Server.UrlEncode( valueArray[j] );

bill

hecsan07 said:
I tried that but it returns something that looks like this:

"/bscore/topmovers/_hpc/_1/016305.htmNRMODE=Published&NRORIGINALURL=%2fbscor
e%2ftopmovers%2fdefault.htm&NRNODEGUID=%7b428F5151-FE96-49B9-9178-8F1A9D59A3
16%7d&NRCACHEHINT=ModifyLoggedIn"

I am afraid this is not the right URL. I am not much of an expert, but the
.htm is repeated over several times there. I don't fully understand the %
signs neither, but I guess that relates to the path in my pc.

I tried this:

// Load NameValueCollection object.
NameValueCollection coll = Request.QueryString;

// Get names of all keys into a string array.
string[] keyArray = coll.AllKeys;

for (int i = 0; i < keyArray.Length; i++)
{
redirectTo += keyArray + "=";
string[] valueArray = coll.GetValues(keyArray);

for (int j = 0; j < valueArray.Length; j++)
{
redirectTo += valueArray[j];
}
}

But the result is pretty much the same.

William F. Robertson said:
Request.QueryString.ToString() will return all of them.

bill


paste
it of
the
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top