23

What's the easiest / standard way to retrieve the GET (in URL) variables passed to a .aspx (VB) page?

Captain
  • 420
  • 5
  • 14
Steven
  • 13,501
  • 27
  • 102
  • 146
  • Here is an example from SO on looping through the GET postback values. [http://stackoverflow.com/questions/562943/looping-through-a-request-querystring-in-vb-net](http://stackoverflow.com/questions/562943/looping-through-a-request-querystring-in-vb-net) – Zachary Jun 23 '09 at 16:08

3 Answers3

50

You can use the following:

Example URL: http://www.whatever.com?hello=goodbye&goodbye=hello

string value = Request.QueryString("hello");

Value will be goodbye

or

foreach(string key in Request.QueryString)
{
    Response.write(Request.QueryString(key))
}
Paul B.
  • 2,394
  • 27
  • 47
Jonathan Mayhak
  • 12,376
  • 3
  • 21
  • 17
7

Look at the Request.QueryString collection

Clyde
  • 8,017
  • 11
  • 56
  • 87
1

if you have a path :

www.stackoverEvan.com/question/directory-lookup.asp?name=Evan&age=16

If you do :

Hi ,  <%= Request.QueryString("name") %>.  
Your age is  <%= Request.QueryString("age") %>. 

Output :

Welcome, Evan. Your age is 16

But as your specifying it's in VB the optimal way would be like :

Path :

http://localhost/script/directory/NAMES.ASP?Q=Evan&Q=Bhops

Code :

--- Names.asp --- 
<% 
  For Each item In Request.QueryString("Q") 
    Response.Write Request.QueryString("Q")(item) & "<BR>" 
  Next 
%> 

Output :

Evan
Bhops