HTTP Request

Question 1:
Is there a way to retrieve the first parameter passed in a query string if you don't know what the name of the parameter is?

For example:

If you don't know the name of the parameter is fullname, is there a way to get its value?

Question 2:
What if the parameter is passed using another way other than query string. All that I know is that there will be only one parameter that will be passed. Is there a universal way of retrieving this parameter?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
There are basically only two ways to pass data to a URL.  'GET' which passes the data in a query string as you show above and 'POST' which passes the data in a POST string which is hidden from the browser.

And this:
dim key
for each key in Request.Querystring
Response.Write key & ": " & Request.Querystring(key) & "<BR>"

Open in new window

Dave BaldwinFixer of ProblemsCommented:
Here is a simple demo in Classic ASP.  There should be something almost identical in ASP.NET.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

<title>ASP Query String</title>
<h1>ASP Query String</h1>
<p>Click for demo: 
<a href="ASPQueryString.asp?name=Fred&pet=Boswer">ASPQueryString.asp?name=Fred&pet=Boswer</a></p>

<p>List of Query String items.</p>
<% dim key
for each key in Request.Querystring
Response.Write key & ": " & Request.Querystring(key) & "<BR>"

Open in new window

John BhattManagerCommented:
You can use HttpRequest.QueryString class to get all querystrings. Then you can separate using below code.
foreach (String key in Request.QueryString.AllKeys)
    Response.Write("QueryString Name: " + key + " QueryString Value: " + Request.QueryString[key]);

Open in new window

This code is used to print all QueryString from browser, you can get all list inside a textbox of somewhere else where you can validate and process as your requirement.

However, there are other ways also to pass data from one page to other pages, other options are described with example in a blog post.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.